Overview:
virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.
Purpose:
In this article, you will learn how to install VirtualEnv & Activate of python3 on Windows 10.
Target Audience:
For those whom want to create a virtual running environment of python without break system tools or other projects. This is optional if you don't care about the above benefit. The TA should have the basic knowledge of python, pip, VirtualEnv and Windows command line under PowerShell.
Pre-requirement:
Please refer the follow link to install the python and pip if you never do it in your Windows 10.
How to install python3 and pip on Windows 10?
Procedures:
1. Install virtualenv: pip install virtualenv
# Open a PowerShell by normal user [username]
PS C:\Users\[username]> pip install virtualenv
Collecting virtualenv
Downloading virtualenv-20.4.7-py2.py3-none-any.whl (7.2 MB)
|████████████████████████████████| 7.2 MB 6.4 MB/s
Collecting six<2,>=1.9.0
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting distlib<1,>=0.3.1
Downloading distlib-0.3.2-py2.py3-none-any.whl (338 kB)
|████████████████████████████████| 338 kB 595 kB/s
Collecting filelock<4,>=3.0.0
Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
Collecting appdirs<2,>=1.4.3
Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Installing collected packages: six, filelock, distlib, appdirs, virtualenv
WARNING: The script virtualenv.exe is installed in 'C:\Users\[username]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed appdirs-1.4.4 distlib-0.3.2 filelock-3.0.12 six-1.16.0 virtualenv-20.4.7
2. Append path of the script virtualenv.exe is installed.
In the above example, please append "C:\Users\[username]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts" to PATH.
Note: Please change [username] by your real user name
A. In Search, search for and then select: System (Control Panel)
B. Click the Advanced system settings link.
C. Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
D. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
E. Reopen Command prompt window, and run your virtualenv code.
3. Create virtualenv in the directory you are in: virtualenv <env_name>
PS C:\Users\[username]> virtualenv redfish
created virtual environment CPython3.9.6.final.0-64 in 17422ms
creator Venv(dest=C:\Users\ch.huang789\redfish, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Windows)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\ch.huang789\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\Local\pypa\virtualenv)
added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2
activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
4. Activate virtualenv: <env_name>\Scripts\activate
PS C:\Users\[username]> redfish\Scripts\activate
(redfish) PS C:\Users\[username]>
--- End of this article ---
Comments
0 comments
Please sign in to leave a comment.