Pcharm profile is not working
I get this error.
Traceback (most recent call last):
Snapshot saved to /Users/hle392/Library/Caches/PyCharm2019.1/snapshots/Multi-Armed-Bandit4.pstat
File "/Applications/PyCharm 2.app/Contents/helpers/profiler/run_profiler.py", line 173, in <module>
profiler.run(file)
File "/Applications/PyCharm 2.app/Contents/helpers/profiler/run_profiler.py", line 89, in run
execfile(file, globals, globals) # execute the script
File "/Applications/PyCharm 2.app/Contents/helpers/profiler/prof_util.py", line 30, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/hle392/workspaces/git_repo_auto/demo/demo-123/venv-0227/lib/python3.6/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
ModuleNotFoundError: No module named '__main__.app'; '__main__' is not a package
Please sign in to leave a comment.
Here is the pycharm details.
PyCharm 2019.1.3 (Professional Edition)
Build #PY-191.7479.30, built on May 29, 2019
Licensed to PyCharm Evaluator
Expiration date: July 4, 2019
JRE: 11.0.2+9-b159.60 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.5
Could you please take a screenshot of the run configuration you used for profiling?
Here you go.
The same configuration works if I Run or Debut. Just the Profile doesn't work. The main reason for me to go to Professional Edition is that I wanted to use profiler.
Could you switch to Script path target type instead of a module?
Its the same error.
Can you give me documentation around when to use Module Name vs Script path vs Custom?
FLASK_APP = bandits/rest/app.py
FLASK_ENV = development
FLASK_DEBUG = 0
In folder /Users/hle392/workspaces/git_repo_auto/Mktg-Nav-Multi-Armed-Bandit/Multi-Armed-Bandit
/Users/hle392/workspaces/git_repo_auto/Mktg-Nav-Multi-Armed-Bandit/Multi-Armed-Bandit/venv-0227/bin/python "/Applications/PyCharm 2.app/Contents/helpers/profiler/run_profiler.py" 127.0.0.1 55745 -m flask run -h 0.0.0.0
Starting cProfile profiler
Traceback (most recent call last):
Snapshot saved to /Users/hle392/Library/Caches/PyCharm2019.1/snapshots/Multi-Armed-Bandit12.pstat
File "/Applications/PyCharm 2.app/Contents/helpers/profiler/run_profiler.py", line 173, in <module>
profiler.run(file)
File "/Applications/PyCharm 2.app/Contents/helpers/profiler/run_profiler.py", line 89, in run
execfile(file, globals, globals) # execute the script
File "/Applications/PyCharm 2.app/Contents/helpers/profiler/prof_util.py", line 30, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/hle392/workspaces/git_repo_auto/Mktg-Nav-Multi-Armed-Bandit/Multi-Armed-Bandit/venv-0227/lib/python3.6/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
ModuleNotFoundError: No module named '__main__.app'; '__main__' is not a package
Process finished with exit code 1
It changes FLASK_APP environment variable. It is possible for you to share the project or a relevant part of it with us? Is it necessary to edit the PYTHONPATH in run configuration?
I did not understand what you are talking about FLASK_APP environment variable.
Are you asking me to remove PYTHONPATH from Environment variable. If yes, i tried and I get the same error.
Are you asking me to remove -h 0.0.0.0 from additional option? If yes, I tried that and I get the same error.
Can you provide me an example of run configuration setup ?
More over with my configuration I am able to run and debut. Its just profile is not working.
I reproduced the problem on my side, looks like the culprit is a relative import which can't be correctly handled by the profiler. The corresponding ticket in Pycharm's bug tracker is https://youtrack.jetbrains.com/issue/PY-28509 I bumped the priority to Major, sorry for the inconvenience.
I'm also having this issue.
I am also having the same error.
Is there a workaround until you have the fix?
I'm also getting this with Flask. flask/logging.py line 17
from .globals import request
ImportError: attempted relative import with no known parent package
@Brian
Please vote for https://youtrack.jetbrains.com/issue/PY-28509 and follow it for updates.