简体   繁体   中英

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.

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!

Well, I still don't know why this was happening -- it persisted through deleting and recreating the venv (obviously), but when I deleted the entire folder, that somehow cleared it up. I just copied the code into a new directory in the same parent and everything seems to be working ¯\\_(ツ)_/¯

If anyone knows what would cause this in my case I still welcome input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM