473,395 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Python site-packages and import

(apologies for starting a new thread - Google can't retrieve the other
message for some reason)

Yes, /usr/lib/python/site-packages is in sys.path. This series of
commands should explain what I mean: I've put the Python ID3 module in
a sub-directory of site-packages as an illustration.

pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/
ID3.py ID3.pyc ID3.pyo README apt_inst.so apt_pkg.so apt_proxy
bsddb3 debconf.py debconf.pyc debconf.pyo id3 pj twisted

pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/apt_proxy/
__init__.py __init__.pyo apt_proxy.pyc apt_proxy_conf.py
apt_proxy_conf.pyo apt_proxytap.pyc memleak.py memleak.pyo
misc.pyc packages.py packages.pyo
__init__.pyc apt_proxy.py apt_proxy.pyo apt_proxy_conf.pyc
apt_proxytap.py apt_proxytap.pyo memleak.pyc misc.py
misc.pyo packages.pyc twisted_compat

pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/id3
ID3.py ID3.pyc ID3.pyo

pzs@bonnie:~$ python
Python 2.3.5 (#2, Feb 9 2005, 00:38:15)
[GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import sys
sys.path ['', '/usr/lib/python23.zip', '/usr/lib/python2.3',
'/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk',
'/usr/lib/python2.3/lib-dynload',
'/usr/local/lib/python2.3/site-packages',
'/usr/lib/python2.3/site-packages'] import apt_proxy.memleak
import id3.ID3 Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named id3.ID3


Peter
Jul 19 '05 #1
2 5402
th*******@my-deja.com (Peter Saffrey) writes:
pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/id3
ID3.py ID3.pyc ID3.pyo
import id3.ID3 Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named id3.ID3


It is missing a file named "__init__.py" at
/usr/lib/python2.3/site-packages/id3

Without it Python won't consider "import id3" as valid (and consequently won't
import submodules as well).

Just 'touch' the file and try again.

--
Jorge Godoy <go***@ieee.org>
Jul 19 '05 #2
Peter Saffrey wrote:
(apologies for starting a new thread - Google can't retrieve the other
message for some reason)

Yes, /usr/lib/python/site-packages is in sys.path. This series of
commands should explain what I mean: I've put the Python ID3 module in
a sub-directory of site-packages as an illustration.

pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/
ID3.py ID3.pyc ID3.pyo README apt_inst.so apt_pkg.so apt_proxy
bsddb3 debconf.py debconf.pyc debconf.pyo id3 pj twisted

pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/apt_proxy/
__init__.py __init__.pyo apt_proxy.pyc apt_proxy_conf.py
apt_proxy_conf.pyo apt_proxytap.pyc memleak.py memleak.pyo
misc.pyc packages.py packages.pyo
__init__.pyc apt_proxy.py apt_proxy.pyo apt_proxy_conf.pyc
apt_proxytap.py apt_proxytap.pyo memleak.pyc misc.py
misc.pyo packages.pyc twisted_compat

pzs@bonnie:~$ ls /usr/lib/python2.3/site-packages/id3
ID3.py ID3.pyc ID3.pyo

pzs@bonnie:~$ python
Python 2.3.5 (#2, Feb 9 2005, 00:38:15)
[GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import sys
sys.path
['', '/usr/lib/python23.zip', '/usr/lib/python2.3',
'/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk',
'/usr/lib/python2.3/lib-dynload',
'/usr/local/lib/python2.3/site-packages',
'/usr/lib/python2.3/site-packages']
import apt_proxy.memleak
import id3.ID3


Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named id3.ID3


Peter


your site-package/id3 lacks a __init__.py file. '__init__.py' file can
be just an empty file but it needs to be there for python to be
considered as a package.

Alternatively, you can use 'from id3 import ID3' instead of 'import id3.ID3'

Cheers
Maurice
Jul 19 '05 #3

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

Similar topics

14
by: Tim Parkin | last post by:
Terry Ready said: > YUCK< YUCK< YUCK. > <snip> > The pollenation site is one of the worst I have seen. The mockup page > has teeny type that IE will not enlarge. > <snip> > I care that the...
22
by: mattf | last post by:
I've discovered Python and have been trying it out lately as a possible replacement for computations that would ordinarily be done with a commercial package like Matlab or IDL. I'd like to mention...
13
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
40
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I'm really annoyed at Python - and not for the reasons already mentioned on this list. Everyone know that programming is supposed to be a dark art, nearly impossible to learn. Computer code is...
34
by: Victor Kryukov | last post by:
Hello list, our team is going to rewrite our existing web-site, which has a lot of dynamic content and was quickly prototyped some time ago. Today, as we get better idea of what we need, we're...
0
by: Chris Calloway | last post by:
Triangle (NC) Zope and Python Users Group (TriZPUG) is proud to open registration for our fourth annual ultra-low cost Plone and Python training camps, BootCampArama 2008: ...
2
by: Nick Craig-Wood | last post by:
Trent Mick <trentm@activestate.comwrote: Looks great and much faster than the old site! Mind telling us how it is implemented? I'm guessing python/django by the url and the fact that you have...
7
by: Michele Simionato | last post by:
I have noticed that the python-mode for Emacs that comes with the latest Ubuntu is missing the class browser. Moreover if works differently from the python-mode I was used to (for instance CTRL-c-c...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.