Reputation: 1546
I'm trying to import module from local path in Python2.7.10 Shell on Windows
I add local path to sys.path
by:
import sys
sys.path.append('C:\download')
next I try to import by:
from download.program01 import *
but I've got this error:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
from download.program01 import *
ImportError: No module named download.program01
On Linux this code works fine.
Does someone know what is wrong?
Upvotes: 0
Views: 126
Reputation: 599540
If download
is in your pythonpath, then you should import program01
directly.
Also, please don't import *; it makes things very hard to debug. Just do import program01
.
Upvotes: 1
Reputation: 51
put a file __init__.py
in your download folder so that python knows it is a module and do sys.path.append('C:')
instead.
If you want to keep just using path and not create a module file (the __init___.py
) then just keep your code like that but import doing
import program01
Upvotes: 0