How to Activate Virtualenv in Linux

How to activate the virtual environment for python?

Your virtual environment was created with virtualenvwrapper. Activate it with command workon mysite-virtualenv in bash console on PythonAnywhere.

For the web app you need to set it on the "Web" configuration page.

How do I activate a virtualenv inside PyCharm's terminal?

Edit:

According to https://www.jetbrains.com/pycharm/whatsnew/#v2016-3-venv-in-terminal, PyCharm 2016.3 (released Nov 2016) has virutalenv support for terminals out of the box

Auto virtualenv is supported for bash, zsh, fish, and Windows cmd. You
can customize your shell preference in Settings (Preferences) | Tools
| Terminal | check Activate virtaulenv

you also need to make sure to have the path of virtual environment path included in the content root folder of your project structure. You can go to settings (preference) | project | Project Structure | if your environment is not included in the project directory.



***Old Method:***

Create a file .pycharmrc in your home folder with the following contents

source ~/.bashrc
source ~/pycharmvenv/bin/activate

Use your virtualenv path as the last parameter.

Then set the shell Preferences->Project Settings->Shell path to

/bin/bash --rcfile ~/.pycharmrc

How to leave/exit/deactivate a Python virtualenv

Usually, activating a virtualenv gives you a shell function named:

$ deactivate

which puts things back to normal.

I have just looked specifically again at the code for virtualenvwrapper, and, yes, it too supports deactivate as the way to escape from all virtualenvs.

If you are trying to leave an Anaconda environment, the command depends upon your version of conda. Recent versions (like 4.6) install a conda function directly in your shell, in which case you run:

conda deactivate

Older conda versions instead implement deactivation using a stand-alone script:

source deactivate

How to activate python env via linux script?

Update

thanks to @Charles Duffy @alaniwi

source /home/username/.local/env_myapp/bin/activate
echo "check - activate env"

now the Script starts my env in the terminal.

(did know how to close the Question, via Question comments. so i wrote the answers of @Charles Duffy @alaniwi here)



Related Topics



Leave a reply



Submit