For activation there is a script that activates a virtualenv from an already running python interpeter using execfile('C:/path/to/virtualev/Scripts/activate_this.py', dict(__file__='C:/path/to/virtualev/Scripts/activate_this.py'))
. However since I can still import packages that are not in the virtualenv from the current python script I am confused about how it works.
For deactivation there is no python script at all.
What should I do?
To install virtualenv, just use pip install virtualenv . To create a virtual environment directory with it, type virtualenv /path/to/directory . Activating and deactivating the virtual environment works the same way as it does for virtual environments in Python 3 (see above).
To activate virtualenv on Windows, first, install the pip. For this purpose, you can download and execute the latest Python installer. Next, install and create virtualenv on Windows using the pip package manager. Then, activate it using the “venvironment\Scripts\activate” command.
You can exit from the virtualenv using exit command, or by pressing Ctrl+d.
Note: Before installing a package, look for the name of your virtual environment within parentheses just before your command prompt. In the example above, the name of the environment is venv . If the name shows up, then you know that your virtual environment is active, and you can install your external dependencies.
From part of the VirtualEnv homepage.
You must use the custom Python interpreter to install libraries. But to use libraries, you just have to be sure the path is correct. A script is available to correct the path. You can setup the environment like:
activate_this = '/path/to/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
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