C:\Program Files\Python311\python.exe: can't open file 'C:\\Program': [Errno 2] No such file or directory
When i try to debug my project I am seeing the following error.
```
* Serving Flask app 'app'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
* Restarting with stat
C:\Program Files\Python311\python.exe: can't open file 'C:\\Program': [Errno 2] No such file or directory
Process finished with exit code 2
```
Debugging till the point where this error shows up on the console, i have discovered that python subprocess Popen() cannot work with paths that have spaces in them like "C:\Program Files"
I am not 100% sure about this because it is difficult to debug built in library subprocess.
Debugging the project worked fine earlier. It started breaking all of a sudden.
请先登录再写评论。
Another workaround:
I created a directory junction.
And then run PyCharm at C:\PyCharm\bin\pycharm64.exe
I'm using Python 3.10 and started getting this error today.
I'm using Python 3.11 and started getting this error today.
Updated the PyCharm version to: PyCharm 2023.1.4 this morning and the problem is still not resolved.
Pycharm has shipped a faulty product
you will need to install pycharm in such a way that there are no spaces in the path to pydev.py
Mine was C:/Program Files/PyCharm Community Edition/plugins/python-ce/helpers/pydev/pydevd.py
there was spaces in Program Files/PyCharm Community Edition/...
i have now installed pycharm in such a way that there are no spaces
C:/Users/<user>/PyCharm/plugins/python-ce/helpers/pydev/pydevd.py
Have the same problem. Directory junction helped.
Hasanbadsha creating a directory junction to the source of PyCharm worked out for me. Just as Juangabriel Lorenzo wrote.
1. Open cmd.exe.
2. Run `mklink /J C:\PyCharm "C:\Path\To\Your\PyCharm Community or Professional Edition 2022.3.2"`
3. Run pycharm `C:\PyCharm\bin\pycharm.bat`.
Perhaps symlink could also work, but i didn't test it.
Juangabriel's answer steered me in the correct direction. After I created the junction (Community Edition 2023.1), I took one more step of edited the desktop shortcut to have a target of C:\PyCharm\bin\pycharm64.exe. I used to have to do this back in my Java days, too. I guess every version upgrade I'll just have to go back and update the junction to point to the newer directory.
Same issue on Community Edition
PyCharm 2023.1.4 (Community Edition)
Build #PC-231.9225.15, built on July 11, 2023
Runtime version: 17.0.7+10-b829.16 amd64
I uninstalled pycharm and installed it in a path without space (C:\Users\Administrator\AppData\Local\Programs\Pycharm), all went well.
By the way, manually installed pycharm can also be recognized by jetbrains toolbox.
PyCharm 2023.1.4 (Community Edition)
Build #PC-231.9225.15, built on July 12, 2023
I reinstalled my pycharm this version to space less path “C:\Users\syedh\PyCharm Community Edition 2023.1.2”
Still getting same error. What am i missing?
I am JS developer, start python flask project 1 week ago.
I solved the problem by following this link: https://stackoverflow.com/a/44668958/3670782
1. use `mklink` command created link path.
2. change flask parameter debug=True to debug=False
Juangabriel Lorenzo 's solution worked
Had the same problem and Wildr Slimshady 's solution worked! Thanks
Downgrading Flask and Werkzeug from 2.3.2 to 2.0.3 fixed the problem for me.