简体   繁体   中英

Fatal Error When Trying To Create A Virtual Venv For Flask?

I am trying to learn FLASK. I am just following this tutorial . I have already created a venv for kivy, and all went right. But now I am learning flask and in CMD, when I pass:

pip install virtualenv

it outputs:

Requirement already satisfied: virtualenv in c:\users\new\appdata\local\programs\python\python39-32\lib\site-packages (20.3.0)
Requirement already satisfied: appdirs<2,>=1.4.3 in c:\users\new\appdata\roaming\python\python39\site-packages (from virtualenv) (1.4.4)
Requirement already satisfied: six<2,>=1.9.0 in c:\users\new\appdata\roaming\python\python39\site-packages (from virtualenv) (1.15.0)
Requirement already satisfied: filelock<4,>=3.0.0 in c:\users\new\appdata\roaming\python\python39\site-packages (from virtualenv) (3.0.12)
Requirement already satisfied: distlib<1,>=0.3.1 in c:\users\new\appdata\roaming\python\python39\site-packages (from virtualenv) (0.3.1)

Then I used:

mkdir newproj
cd newproj

At last:

virtualenv venv

And it said:

Fatal error in launcher: Unable to create process using '"c:\program files\python39-32\python.exe" 
"C:\Program Files\Python39-32\Scripts\virtualenv.exe" ': The system cannot find the file specified.

I tried adding "C:\Program Files\Python39-32\Scripts\virtualenv.exe" to path. But it did not work. How do I fix this?

as of python 3.3 , python is shipped with its built-in virtual environment module venv , it's the official, the standard, the recommended and the difacto module.

refer to: https://docs.python.org/3/library/venv.html#module-venv

so you don't even need to install any 3rd module like virtualenv , pipenv .. to create and manage your virtual environments.

  1. create the root folder for your project
C:\> mkdir newproj
C:\> cd newproj
  1. create the virtual environment, (as good practice and as seen in many well-known projects on github.. named it venv )
C:\newproj> py -m venv venv
  1. activate it
C:\newproj> venv\Scripts\activate

(venv) C:\newproj> pip list
(venv) C:\newproj> pip install flask flask-login ..
  1. to deactivate it
(venv) C:\newproj> deactivate
C:\newproj> 

Try to use:

python3 -m virtualenv venv

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