Pcharm profile is not working

Answered

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

9 comments

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

0

Could you please take a screenshot of the run configuration you used for profiling?

0

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.

0

Could you switch to Script path target type instead of a module?

0

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

 

 

0

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?

0

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.

0

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.

0

Please sign in to leave a comment.