By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

Problem importing packages

P: n/a
I'm trying to create a package containing a number of classes I made,
but I can't get it to work...

My package is structured like this:

X/
__init__.py
A.py
B.py

When I try:
import X.A
python says:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named X.A
As far as I can see, I do it exactly like the 'documentation' says, but
it obviously doesn't work this way. What am I missing? (clear
documentation, obviously...)

For the record, I believe my paths are right. If I do the following, I
can at least import class A:
import sys
sys.path.append('X')
import A


Python version is 2.3.3 on Debian Linux.
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Alban Hertroys wrote:
I'm trying to create a package containing a number of classes I made,
but I can't get it to work...

My package is structured like this:

X/
__init__.py


Doh! I named it __init.py__ instead...
It DOES work using __init__.py.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.