0

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?

0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.