Nick's Blog

Install and configure virtualenv on Windows 10


This article is demo how to install and configure virtualenv on a Windows 10 machine.

Install virtualenv.

Open CMD or PowerShell
PS C:py_projects> pip install virtualenv

Check the current Python version
PS C:py_projects> python –version
Python 3.6.2

Create a new virtualenv environment with python

PS C:py_projects> virtualenv test –python=”C:Program FilesPython36python.exe”
Running virtualenv with interpreter C:Program FilesPython36python.exe
Using base prefix ‘C:\Program Files\Python36’
New python executable in C:py_projectstestScriptspython.exe
Installing setuptools, pip, wheel…done.

If you getting “The path python* (from –python=python*) does not exist” error. That means you have not specify the path of python.exe. And this is different apart from the MacOS and Linux. As you can specify by just using “–python=python3.6.2” for example.

Once finish, you will see a test folder appears in the main directory.

Activate  

You could choose the activate.bat or ps1 depends on what are you using. In this instance, I’m doing this under PowerShell. So I just use the ps script.
PS C:py_projects> .testScriptsactivate.ps1
(test) PS C:py_projects>

You will notice that the virtualenv instance name test appears in the front of the PowerShell, which means you have already inside of virtualenv.

Deactivate

Same theory apply. run the deactivate
(test) PS C:py_projects> deactivate
PS C:py_projects> ls

You can install the extension within the test virtualenv to configure your environment.