pythonpath

L

luca72

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

Thanks
Luca

I'm under linux
 
A

Albert Hopkins

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top