FallenSpaces
FallenSpaces

Reputation: 352

How to set virtualenv to another directory?

I had a problem come up when I was forced to change my project directory name.

First Virtualenvwrapper didn't see my projects, so I changed the environment variable of WORKON_HOME to the new project directory. I could then activate my envs. But now when my project is doing anything, it thinks it's in the old directory, not the new one. I can't figure out how to change this. I've looked in the reference material, and looked for the place that actually points to where the projects are, but I had no luck with either. Please help.

Upvotes: 6

Views: 4919

Answers (1)

auturgist
auturgist

Reputation: 96

It sounds like you want to set an already-created virtual environment to a directory that contains your project. One way that I am familiar with to do the following, based on the virtualenvwrapper documentation.

  1. Activate your desired virtual env workon myvirtualenv
  2. Change your directory to your desired project directory
    $ cd my/project/dir
  3. Set your virtualenv project to the current directory
    $ setvirtualenvproject

The default is to use the current directory. The full syntax is:

$ setvirtualenvproject [virtualenv_path project_path]

I hope this helps!

Upvotes: 8

Related Questions