Additional steps for virtualenvwrapper-powershell. Recommend add to documentation?

Skip to first unread message

Derek Lee

Apr 9, 2015, 10:53:13 AM4/9/15
Finally managed to get it working.  Here are a few things you might have to do to get it to work.

pip install virtualenv
pip install virtualenvwrapper

After installing, you'll need to import the wrapper module in PowerShell

import-module virtualenvwrapper

Here's where the bugs start.  There are two that I faced:

Bug A:
''C:\Users\current_user/.virtualenvs' does not exist. Create it or set env:WORKON_HOME to an existing directory.

Fix A: create the missing directory
mkdir '~\.virtualenvs'
set $env:WORKON_HOME '~\.virtualenvs'

Bug B: 
Set-ItemProperty : Cannot find path 'HKCU:\Software\Python\PythonCore\2.7\InstallPath' because it does not exist.

Fix B: Restore the Python Registry in Windows
Create a fix_python.reg file and add the following lines:
Windows Registry Editor Version 5.00


[HKEY_CURRENT_USER\Software\Python\Pythoncore\2.7\PythonPath] @="C:\python27;C:\python27\Lib\;C:\python27\DLLs\"

Run the file and follow the prompts to load the new values into the Windows Registry

virtualenvwrapper-powershell is now ready to go!

After using it for a while you'll realize that you have to import the module every time you want to use it.  To fix that, you can configure your PowerShell profile so that the module is loaded every time you open up a PowerShell window.

New-Item -Path $Profile.CurrentUserAllHosts -Type file -Force

Navigate to C:\Users\current_user\Documents\WindowsPowerShell\profile.ps1, and add the command you used to import.

Import-Module virtualenvwrapper

virtualenvwrapper should now be available every time you run PowerShell

Reply all
Reply to author
0 new messages