I misspelled the name of the virtualenv
while initializing it using:
$ virtualenv vnev
I actually intended to create the environment with the name venv
. Having tried to rename the vnev
folder to venv
, I find that this doesn't provide much help. The name of the activate environment still renames the old vnev
.
$ mv vnev venv $ . venv/bin/activate (vnev) $ deactivate
I would like to know how to go about renaming the environment?
By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
Yes. It is possible to move it on the same platform. You can use --relocatable on an existing environment.
By default virtualenv does not support the renaming of environments. It is safer to just delete the virtualenv directory and create a new one with the correct name. You can do this by:
source vnev/bin/activate
pip freeze > requirements.txt
rm -r vnev/
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
If recreating is not an option there are 3rd party tools like virtualenv-mv that might be helpful.
Alternatively you can use virtualenvwrapper which provides the cpvirtualenv
command to copy or rename virtualenvs.
If you use virtualenvwrapper this can be done by:
$ cpvirtualenv <wrong_name> <correct_name> $ rmvirtualenv <wrong_name>
Also, FYI, to rename a conda virtualenvironment, check out this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With