I know that there are a low of similar issues, but none helped me, so I am writing a new one. Here is my directory structure:
- mypackage
- __init__.py
- run.py
- requirements.txt
The run.py content:
from mypackage import app
app.run(host='localhost', port=3648)
The mypackage/_init_.py content:
from flask import Flask
app = Flask(__name__)
And here is the full error:
C:\...\parser>python run.py
Traceback (most recent call last):
File "run.py", line 1, in <module>
from mypackage import app
ImportError: cannot import name 'app' from 'mypackage' (unknown location)
It seems to be a bug or I am doing something wrong..
UPDATE: Environment check for PYTHONPATH:
Traceback (most recent call last):
File "run.py", line 6, in <module>
print(os.environ['PYTHONPATH'])
File "C:\Users\white\AppData\Local\Programs\Python\Python37\lib\os.py", line 678, in __getitem__
raise KeyError(key) from None
KeyError: 'PYTHONPATH'