473,594 Members | 2,747 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 5420
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
1956
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 glass
22
1518
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 sci/tech Python community out there.- This was something of a surprise. If you look at the python.org...
13
2148
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
2701
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 the Matrix... Python takes all of that away. It is just too readable. Even beginners can...
34
4338
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* objects, nice clean syntax etc.
0
1742
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
1096
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
2129
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? Michele Simionato
0
8246
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8368
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8000
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8231
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6652
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5404
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2383
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
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.