473,545 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.py c 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.py o 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.memle ak
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 5413
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__.p y" 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.py c 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.py o 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.memle ak
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
1948
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 site remain physically readable and that it remain a > vehicle for information rather than childish egos. > <snip> > Using IE6, I need a magnifying...
22
1512
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 a few things I've run across that have either surprised me or kept me from doing things the way I'd like to. 1) -There's a large and active...
13
2143
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
2691
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 supposed to be something impossible to read to the common person and yet reveal their secrets to the initiated - just remember the code displayed in...
34
4324
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 going to re-write everything from scratch. Python is an obvious candidate for our team: everybody knows it, everybody likes it, it has *real*...
0
1739
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: http://trizpug.org/boot-camp/2008/ Registration is now open for: PyCamp: Python Boot Camp, August 4 - 8
2
1094
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 python stuff on your home pages but I could be wrong! -- Nick Craig-Wood <nick@craig-wood.com-- http://www.craig-wood.com/nick
7
2121
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 works as CTRL-c-! whereas CTRL-c-! is missing, etc). How can I go back to the old python-mode or at least how do I get back the class browser? ...
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.