Python virtual environments are the common way to install and collect all python packages required for a specific project.
The setup process for your personal virtual environment is also described in pycharm.
The preferred way is using the virtualenvwrapper - so you can use: workon to load your virtual environment:
mkvirtualenv --python=`which python<VERSION>` <VENV_NAME>
You can also create basic virtual environments (unmanaged):
python -m venv <Path-To-VEnv>
For some cases it might be necessary to use inherited system site packages (e.g VTK). This will include all python packages installed on the system to be available in your virtual environment. It is advised only (not) to use for environments where it is really necessary.
mkvirtualenv <VENV_NAME> --system-site-packages
python -m venv <Path-To-VEnv> --system-site-packages
The virtual environments created with mkvirtualenv can also be used and managed within PyCharm.
You can activate the virtual environment in any terminal by sourcing the activation script:
source <Path-to-VEnv>/bin/activate
Deactivate the virtual environment by typing:
deactivate
First deactivate the virtual environment:
deactivate
When using virtualenvwrapper one can simply use the command:
rmvirtualenv <VENV_NAME>
to delete it. If the virtual environment was manually created one must delete the folder by hand:
rm -r <Path-to-VEnv>/<VENV_NAME>
PIP (documentation) is the tool to manage python modules inside your virtual environment.
pip install <Package-Name>
pip uninstall <Package-Name>
pip install --upgrade <Package-Name>
pip install --user <Package-Name>
Create a new alias in your
~/.bash_aliases
file by inserting this line:
pip-upd='pip freeze --local | grep -v ^[eV] | cut -d = -f 1 | xargs pip install -U'
Explanation: This command
pip install -r <file name>
Collect your desired python version
wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tgz tar xzf Python-3.x.x.tgz cd Python-3.x.x
and configure/compile your python:
./configure --enable-optimizations --prefix=/home/username/.local make altinstall
Make altinstall avoids, that you try to overwrite the system python. You can call your own python now by “python3.x”