472,333 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 software developers and data experts.

List of modules available for import inside Python?

Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules
Also, is there anything like Cpan for Python?
Aug 28 '08 #1
16 7012
On Wed, Aug 27, 2008 at 9:21 PM, ssecorp <ci**********@gmail.comwrote:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules
Also, is there anything like Cpan for Python?
The closest thing would be PyPI (the Python Package Index)
[http://pypi.python.org/pypi], and easy_install (a package manager for
Python) [http://peak.telecommunity.com/DevCenter/EasyInstall].

- Chris
========
Follow the path of the Iguana...
Rebertia: http://rebertia.com
Blog: http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list
Aug 28 '08 #2
On Thu, Aug 28, 2008 at 2:21 PM, ssecorp <ci**********@gmail.comwrote:
Also, is there anything like Cpan for Python?
Try the Python Cheese Shop / PyPi

http://pypi.python.org/pypi

cheers
James

--
--
-- "Problems are solved by method"
Aug 28 '08 #3
ssecorp wrote:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules
there's a helper script in the 2.5 source code kit that locates all
existing standard modules:

http://svn.python.org/projects/pytho...listmodules.py

to get all modules, remove the for-loop that follows after the comment
"get rid of site packages".

also see:

http://effbot.org/zone/listmodules-cgi.htm

</F>

Aug 28 '08 #4
On Aug 28, 6:21*am, ssecorp <circularf...@gmail.comwrote:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
Try:
>>help()
helpmodules
Please wait a moment while I gather a list of all available modules...
<snip>
Aug 28 '08 #5
On Aug 28, 12:21 am, ssecorp <circularf...@gmail.comwrote:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules

Also, is there anything like Cpan for Python?
Isn't the most obvious answer to the first question this link?

http://docs.python.org/modindex.html
Aug 28 '08 #6
pr*******@latinmail.com wrote:
>Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules

Also, is there anything like Cpan for Python?

Isn't the most obvious answer to the first question this link?
depends on whether you want a list of the modules that you might be able
to import, or the modules that are actually present on your system.

</F>

Aug 28 '08 #7
On Aug 27, 11:04*pm, Fredrik Lundh <fred...@pythonware.comwrote:
ssecorp wrote:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:
import.modules

there's a helper script in the 2.5 source code kit that locates all
existing standard modules:

http://svn.python.org/projects/pytho...listmodules.py

to get all modules, remove the for-loop that follows after the comment
"get rid of site packages".

also see:

http://effbot.org/zone/listmodules-cgi.htm

</F>
I like to direct new users to pydoc's built-in HTTP server:

import pydoc
pydoc.gui()
(then click the 'open browser' button)
Aug 28 '08 #8
Am Thu, 28 Aug 2008 11:23:01 -0700 schrieb Jason Scheirer:
>
I like to direct new users to pydoc's built-in HTTP server:

import pydoc
pydoc.gui()
(then click the 'open browser' button)
Now, this is cool !

Thanks a lot!

Martin

Aug 28 '08 #9
Michele Simionato wrote:
On Aug 28, 6:21Â*am, ssecorp <circularf...@gmail.comwrote:
>Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:

Try:
>>>help()
helpmodules
Please wait a moment while I gather a list of all available modules...
<snip>
This looks like it could be a useful tool, but when I try it
I get the following:

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.5/site-packages/reportlab/lib/PyFontify.py:35:
Warning: 'with' will become a reserved keyword in Python 2.6
/usr/lib/python2.5/site-packages/reportlab/lib/PyFontify.py:36:
Warning: 'with' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site.py", line 346, in __call__
return pydoc.help(*args, **kwds)
File "/usr/lib/python2.5/pydoc.py", line 1645, in __call__
self.interact()
File "/usr/lib/python2.5/pydoc.py", line 1663, in interact
self.help(request)
File "/usr/lib/python2.5/pydoc.py", line 1679, in help
elif request == 'modules': self.listmodules()
File "/usr/lib/python2.5/pydoc.py", line 1797, in listmodules
ModuleScanner().run(callback)
File "/usr/lib/python2.5/pydoc.py", line 1848, in run
for importer, modname, ispkg in pkgutil.walk_packages():
File "/usr/lib/python2.5/pkgutil.py", line 110, in walk_packages
__import__(name)
File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line 1342,
in <module>

File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line 927,
in main

UnboundLocalError: local variable 'given_files' referenced before assignment
>>>
which could be because I am fairly free and unrestrained when
it comes to installing stuff, and I see now I have modules
on both /usr/lib/python2.5 and /usr/local/lib/python2.5

Apparently python knows about them both, but I don't know I
haven't introduced an incompatibility somewhere...and that PIL
package showing up at the tail of the errors was one of my
more recent additions...

Any help will be appreciated,

sc

Sep 6 '08 #10
En Sat, 06 Sep 2008 17:18:55 -0300, clurker <no****@spamhaters.comescribió:
Michele Simionato wrote:
>On Aug 28, 6:21*am, ssecorp <circularf...@gmail.comwrote:
>>Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:

Try:
>>>>help()
helpmodules
Please wait a moment while I gather a list of all available modules...
<snip>

This looks like it could be a useful tool, but when I try it
I get the following:

Please wait a moment while I gather a list of all available modules...
[...]
File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line 1342,
in <module>

File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line 927,
in main

UnboundLocalError: local variable 'given_files' referenced before assignment
>>>>
Unfortunately the "modules" help command actually imports all the available packages, and a buggy one may stop the whole process with an error.
Apparently python knows about them both, but I don't know I
haven't introduced an incompatibility somewhere...and that PIL
package showing up at the tail of the errors was one of my
more recent additions...
If import of a package fails, the error reported is not accurate. In this case, probably some other package failed, that itself imported PIL. Line 927 in PIL/__init__.py does not exist.

A quick fix is to replace line 1854 in pydoc.py (ModuleScanner.run) with this one:

for importer, modname, ispkg in pkgutil.walk_packages(onerror=lambda name:None):

(the onerror argument makes it to ignore all errors)

--
Gabriel Genellina

Sep 7 '08 #11
sc
Gabriel Genellina wrote:
En Sat, 06 Sep 2008 17:18:55 -0300, clurker <no****@spamhaters.com>
escribió:
>Michele Simionato wrote:
>>On Aug 28, 6:21Â*am, ssecorp <circularf...@gmail.comwrote:
Is there a way to view all the modules I have available for import
from within Python?
Like writing in the interpreter:

Try:

>help()
helpmodules
Please wait a moment while I gather a list of all available modules...
<snip>

This looks like it could be a useful tool, but when I try it
I get the following:

Please wait a moment while I gather a list of all available modules...
[...]
> File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line
1342,
in <module>

File "/usr/local/lib/python2.5/site-packages/PIL/__init__.py", line
927,
in main

UnboundLocalError: local variable 'given_files' referenced before
assignment
>>>>>

Unfortunately the "modules" help command actually imports all the
available packages, and a buggy one may stop the whole process with an
error.
>Apparently python knows about them both, but I don't know I
haven't introduced an incompatibility somewhere...and that PIL
package showing up at the tail of the errors was one of my
more recent additions...

If import of a package fails, the error reported is not accurate. In this
case, probably some other package failed, that itself imported PIL. Line
927 in PIL/__init__.py does not exist.

A quick fix is to replace line 1854 in pydoc.py (ModuleScanner.run) with
this one:

for importer, modname, ispkg in
pkgutil.walk_packages(onerror=lambda name:None):

(the onerror argument makes it to ignore all errors)
nice Gabriel, thanx! At least now "help(); modules" gives me a beautiful
list -- I guess I'll find out what the buggy module is if/when I try
to use it...(all PIL/__init__.py is is about 15 lines of comments
(referencing a README I can't find))

sc

Sep 7 '08 #12
A quick fix is to replace line 1854 in pydoc.py (ModuleScanner.run) with
this one:
* * * * for importer, modname, ispkg in
* * * * pkgutil.walk_packages(onerror=lambda name:None):
(the onerror argument makes it to ignore all errors)
well not all, for example
GLUT: Fatal Error in summon: could not open display: :0.0

So to refine the question:
how can I list all modules that might be importable on my system,
without actually importing them all ?

(How about a "pydoc2" that's well thought out, doesn't crash ...
let me ask more knowledgable people, what's a good small help system
as model ?
)

cheers
-- denis

Sep 10 '08 #13
de*****@t-online.de wrote:
how can I list all modules that might be importable on my system,
without actually importing them all ?
I'm pretty sure I mentioned a way to do that back when this thread was
opened. let's see, yes, here it is:

....

there's a helper script in the 2.5 source code kit that locates all
existing standard modules:

http://svn.python.org/projects/pytho...listmodules.py

to get all modules, remove the for-loop that follows after the comment
"get rid of site packages".

also see:

http://effbot.org/zone/listmodules-cgi.htm

....

</F>

Sep 10 '08 #14
On Sep 10, 1:45*pm, Fredrik Lundh <fred...@pythonware.comwrote:
deni...@t-online.de wrote:
* *how can I list all modules that might be importable on my system,
* *without actually importing them all ?

I'm pretty sure I mentioned a way to do that back when this thread was
opened. *let's see, yes, here it is:

...

there's a helper script in the 2.5 source code kit that locates all
existing standard modules:

http://svn.python.org/projects/pytho...listmodules.py

to get all modules, remove the for-loop that follows after the comment
"get rid of site packages".
I have just tried the following on my Ubuntu box with the system
Python:

~$ python /usr/lib/python2.5/doc/tools/listmodules.py
/usr/lib/python2.5/doc/tools/listmodules.py:99: DeprecationWarning:
the rgbimg module is deprecated
__import__(m)

** (process:24863): WARNING **: AT_SPI_REGISTRY was not started at
session startup.

** (process:24863): WARNING **: Could not locate registry
location: /usr/lib/xulrunner-1.9.0.1/libxpcom.so
before 3
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot
register existing type `GtkSourceStyleScheme'
__import__(m)
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning:
g_type_set_qdata: assertion `node != NULL' failed
__import__(m)
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot
register existing type `GtkSourceBuffer'
__import__(m)
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning:
g_type_get_qdata: assertion `node != NULL' failed
__import__(m)
Segmentation fault

Interesting, isn't it?

Michele Simionato
Sep 10 '08 #15
Michele Simionato wrote:
I have just tried the following on my Ubuntu box with the system
Python:

~$ python /usr/lib/python2.5/doc/tools/listmodules.py
/usr/lib/python2.5/doc/tools/listmodules.py:99: DeprecationWarning:
the rgbimg module is deprecated
__import__(m)

** (process:24863): WARNING **: AT_SPI_REGISTRY was not started at
session startup.

** (process:24863): WARNING **: Could not locate registry
location: /usr/lib/xulrunner-1.9.0.1/libxpcom.so
before 3
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot
register existing type `GtkSourceStyleScheme'
__import__(m)
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning:
g_type_set_qdata: assertion `node != NULL' failed
__import__(m)
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot
register existing type `GtkSourceBuffer'
__import__(m)
/usr/lib/python2.5/doc/tools/listmodules.py:99: Warning:
g_type_get_qdata: assertion `node != NULL' failed
__import__(m)
Segmentation fault

Interesting, isn't it?
it does indeed import modules found in the path if they appear to be
Python C extensions. why Ubuntu puts badly written C modules in their
default Python path is more than I can tell...

</F>

Sep 10 '08 #16
On 2008-09-10, de*****@t-online.de <de*****@t-online.dewrote:
(snip) ...

So to refine the question:
how can I list all modules that might be importable on my system,
without actually importing them all ?

(How about a "pydoc2" that's well thought out, doesn't crash ...
let me ask more knowledgable people, what's a good small help system
as model ?
)


I'm constantly finding myself wishing for this feature -
something of the "apropos"/"whatis" of the linux shell (and debian's
"apt-cache search" and "apt-cache show" which allow you to search
and query before you install).
(Matlab's "help" and "lookfor" commands cover this too.)

Is there a reason this type of information hasn't been made available
by default in the help system?
I'm constantly using find, grep and Usenet to find out what python tools
I can use.

Anita

Sep 10 '08 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Doug Kearns | last post by:
Is this the best/simplest way to generate a module list? python -c 'from pydoc import help; help("modules")' Thanks, Doug
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a...
12
by: qwweeeit | last post by:
The pythonic way of programming requires, as far as I know, to spread a big application in plenty of more manageable scripts, using import or from...
5
by: bruce | last post by:
hi... i'm trying to deal with multi-dimension lists/arrays i'd like to define a multi-dimension string list, and then manipulate the list as i...
2
by: dhable | last post by:
I think I'm still missing something in how python is handling packages and it's mixing me up. I have a package with three files (modules?) like so:...
17
by: mohan | last post by:
Hi Guys, I've been using the following IDE, "Pythonwin - Python IDE and GUI Framework for Windows. Copyright 1994-2001 Mark Hammond " ...
0
by: PhongPham | last post by:
I used environment on Fedora core 6 and tried with python 2.5.2 package on board chip mips and platform 2.6 is ok (although when "make" still have...
4
by: srinivas | last post by:
hi friends i am new to python programming. i am using Python 2.5 and IDLE as editor. i have developed some functions in python those will be...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.