Restarting with stat error when debugging flask app with PyCharm debugger

495 views Asked by At

I'm building a small flask app and I had a few errors I wanted to try and fix with the PyCharm debugger, but when I try to run the debugger the following pops up:

*Restarting with stat

C:\Users\nare2\AppData\Local\Programs\Python\Python310\python.exe: can't open file 'C:\Program': [Errno 2] No such file or directory

Here's the relevant (last) lines of my code:

>     if __name__ == "__main__":
>         with app.app_context():
>             db.create_all()
>             app.run(debug=True, port=5001)
2

There are 2 answers

1
Dean On

I meet the error too, and can not solve this problem, and I think the problem caused by the Pycharm, It's a software bug.

0
Ewoud On

I found a solution at the PyCharm support forum to make sure that you don't install PyCharm in a location with spaces (which is quite difficult on Windows machines).

A quick work-around is to make a Junction to the installation directory of PyCharm by using a path that does not contain any spaces, using the command line, e.g.:

mklink /J C:\software\PyCharm "C:\Program Files\JetBrains\PyCharm Community Edition 2022.3.2"

And then start PyCharm from the \bin folder in the newly created junction. Alternatively update the symlink from the Windows Start menu to point to this new location.