Python3 venv: Can I rename an env directory?

I am using Python 3.4 for Windows. I created a virtual environment using

python c: \ Python34 \ Tools \ Scripts \ pyvenv.py foo

Then activate it

Foo \ Scripts \ activate.bat

And installed several libraries in it.

Question: Is it safe to rename the venv folder "foo" to "bar"? That is, as soon as I rename foo to bar and then activate it with

bar \ Scripts \ activate.bat

will it work

What problems may arise - any settings of environment variables and absolute paths.

+6
source share
1 answer

To do this, you must use virtualenv . From docs :

Typically, environments are tied to a specific path. This means that you cannot move the environment or copy it to another computer. You can fix the environment to make it relocatable with the command:

$ virtualenv --relocatable ENV

This will make some of the files created by setuptools or distribute the use of relative paths and modify all scripts to use activate_this.py instead of using the location of the Python interpreter to select the environment.

Note: you must run this after you have installed any packages in the environment. If you make the environment relocatable, then install the new package, you must run virtualenv -relocatable again.

But keep in mind:

The -relocatable option currently has a number of problems and is not guaranteed to work under any circumstances. Perhaps this option will be deprecated in a future version of virtualenv.

+1
source

All Articles