Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set environment variable WORKON_HOME for virtualenvwrapper-win

I am trying to setup virtualenvwrapper-win on a usb drive as part of a python development environment. In https://github.com/davidmarble/virtualenvwrapper-win it states:

Optional: Add an environment variable WORKON_HOME to specify the path to store environments. By default, this is %USERPROFILE%\Envs.

but doesn't explain how to do this. Could someone help with this?

My system python is at:

/f/python27/python
like image 743
user1592380 Avatar asked Jan 07 '14 18:01

user1592380


People also ask

How do I use virtualenvwrapper and virtualenv?

This is really simple. Start by changing directory into the root of our project directory, and then use the virtualenv command-line tool to create a new environment: $ mkdir myproject $ cd myproject $ virtualenv env New python executable in env/bin/python Installing setuptools, pip, wheel... done.

What is pip install virtualenvwrapper win?

This is a port of Doug Hellmann's virtualenvwrapper to Windows batch scripts. The idea behind virtualenvwrapper is to ease usage of Ian Bicking's virtualenv, a tool for creating isolated Python virtual environments, each with their own libraries and site-packages.


2 Answers

AS lguananut said, you are asking how to set an environment variable. Take Win7 as example,

  1. execute command "sysdm.cpl"
  2. Go to Advanced tab, open "Enviroment Variables..."
  3. New a system variable
  4. In pop window, set variable name = WORKON_HOME, value = [your virtual environments root]

relaunch one command prompt, all commands like mkvirtualenv, workon will works.

like image 96
Cypine Avatar answered Sep 26 '22 04:09

Cypine


If you prefer Powershell like me, you could also try the following code.

[Environment]::SetEnvironmentVariable("WORKON_HOME", "C:\Venv", "User")
[Environment]::SetEnvironmentVariable("PROJECT_HOME", "C:\Project", "User")

It will create two environment variables for your current user:

  • WORKON_HOME
  • PROJECT_HOME

Paste the sample code in PowerShell window:

[Environment]::SetEnvironmentVariable("WORKON_HOME", "<Your-Virtual-Environment-Root>", "User")
[Environment]::SetEnvironmentVariable("PROJECT_HOME", "<Your-Project-Root>", "User")

It will populate the variables like

Windows Environment Variable Configuration Result

Hope it helps.

like image 37
eric Avatar answered Sep 26 '22 04:09

eric