pythonpath
Albert Hopkins
marduk at python.net
Mon Mar 1 07:14:19 EST 2010
On Mon, 2010-03-01 at 02:48 -0800, luca72 wrote:
> Sorry for my stupid question if i have to load module from a folder i
> have to append it to the sys path the folder?
> ex:
> if my folder module is /home/lucak904/Scrivania/Luca/enigma2
> i do this :
> import sys
> sys.path.append('/home/lucak904/Scrivania/Luca/enigma2')
> If this is correct why when i write:
> form enigma2 import *
> i get no module named enigma2
There are two reasons for this:
1. enigma2 is not in your namespace. What's inside enigma is. For
example, you can't say "from site-packages import *" because
Python doesn't look at "site-packages". It looks at what's
inside site-packages. If you wanted" enigma2" to be in your
namespace, you should add /home/lucak904/Scrivania/Luca" to your
system path.
2. Even if you did above, it may not work because enigma2 is a
directory. Remember "from x import *" only works for modules and
packages, so if you want "enigma2" to be a package, remember to
add an (empty) __init__.py to the directory.
Hope this helps.
-a
More information about the Python-list
mailing list