A simple guide to install virtual environment with different python version on Windows.
- Objectives:
-
- Install Virtual Environment on Windows
-
- Required Tools:
-
- Python — Python 3 chosen in this case.
- VirtualEnv — Main virtualenv tool.
- VirtualEnvWrapper-Win — VirtualEnv Wrapper for Windows.
-
- Steps:
-
- Install python with python windows installer.
- Add python path to Windows PATH. Python 3 will enable this option for users. If not found, add the following two path (Python 3 sample default path )
- C:\Users\\AppData\Local\Programs\Python\Python36
- C:\Users\MyUserName\AppData\Local\Programs\Python\Python36\Scripts
- pip install virtualenv
- pip install virtualenvwrapper-win
- Main commands use with virtualenv wrapper in windows command prompt
- mkvirtualenv : create a new virtual env
- workon : list all the environment created
- workon : Activate particular environment.
- deactivate: deactivate active environment
- rmvirtualenv : remove target environment.
-
Further notes
- Most of the guide reference from Timmy Reilly’s Blog.
- To create virtualenv with specified python version
- virtualenv -p <path/win dir of python version>
- mkvirtualenv -p <path/win dir of python version>
- Retrieve a list of python modules installed via pip and save to requirement.txt
- pip freeze > requirement.txt
- to install a list of required modules (from other virtual env etc)
- pip install -r requirements.txt
- Likely python3 pip path for win10: C:\Users\xxx\AppData\Local\Programs\Python\Python39\Scripts