Search code examples
pythonflaskpippython-venv

pip in venv on Windows 10: 'Fatal error in launcher: Unable to create process using '"c:\users\..." ' encountered during flask tutorial


I'm going through the Flask tutorial, and I encounter a problem where I can't use pip (and thus anything else really) a venv in Powershell. The same flask app runs correctly in an Ubuntu terminal with Python 3.6.6 in WSL.

The problem seems to depend on the directory, which makes me think it's somehow related to file path length; I enabled long file paths in the windows Group Editor but this hasn't fixed the problem. In the below steps my venv directory is c:\users\rwgpu\google-drive\code\flask-tutorial\winEnvflaskr\ and I experience the error, but everything works correctly in the directory C:\python\test\testVenv. (in each case I'm running the commands in the directory one up from the listed above, flask-tutorial and test respectively)

Minimal steps to reproduce are:

Completely fresh Python 3.7 installation.

Change directory to app folder.

py -m venv winEnvFlaskr

./winEnvFlaskr/Scripts/activate

pip list

The ultimate goal is to then

pip install FLask

and run the Flask tutorial app. Again, all steps work correctly in Bash on Ubuntu in WSL (running its own Python) and in a different windows directory with the same Python 3.7.

After pip list I get the error:

Fatal error in launcher: Unable to create process using '"c:\users\rwgpu\google-drive\code\flask-tutorial\winenvflaskr\scripts\python.exe"  "C:\Users\rwgpu\Google-Drive\Code\flask-tutorial\winEnvFlaskr\Scripts\pip.exe" list'

and if I try

python -m pip list

I get nothing; the terminal hangs for a second and returns with no output. If I run

py -m pip install -U pip

in the bugged venv it will try to install and report success. It will do this again, and will never report "requirement already satisfied" which would be correct.


Solution

  • I had the same problem on Windows with running flask in command line from venv(for example, "(venv)...\flask run"). I resolved the problem with changing path in flask.exe code(open "your_venv\Scripts\flask.exe" with notepad or etc.): in my way I correct the 436-th line at the end; you need to put there "your_absolute_path_to_venv\Scripts\python.exe" instead of the path indicated there. Good luck!