I have created a project like the below one:
project | | --package1 | | | -- <strong>init__py | --module1.py | | --package2 | --__init</strong>.py --module2.py
I want to import module1 into module2, (from package1 import module1)
In PyCharm everything is just working fine. But when I try to open the file "module2.py" from Windows10 command prompt I get ModuleNotFoundError:No module named 'module1' . I was looking for the solution but not a single one worked. I have set environment variable PYTHONPATH = I:\project\package1 I'm using python 3.6Answer1:
By default, python only searches current directory. So you'll need to append the path a bit.
In module 2:
import sys sys.path.append('C:\PathTo\project\package1') import module1
That should fix the issue you were having.