2. Install in Virtual Environments#
If you do not want the installation to occupy your main python’s site-packages (either you are testing or the dependencies may clutter your existing installed packages), install the package in an isolated virtual environment. Two common virtual environments are virtualenv and conda.
2.1. Install in virtualenv
Environment#
Install
virtualenv
:python -m pip install virtualenv
Create a virtual environment and give it a name, such as
glearn_env
python -m virtualenv glearn_env
Activate python in the new environment
source glearn_env/bin/activate
Install
glearn
package with any of the above methods. For instance:python -m pip install glearn
Then, use the package in this environment.
To exit from the environment
deactivate
2.2. Install in conda
Environment#
In the followings, it is assumed anaconda (or miniconda) is installed.
Initialize conda
conda init
You may need to close and reopen your terminal after the above command. Alternatively, instead of the above, you can do
sudo sh $(conda info --root)/etc/profile.d/conda.sh
Create a virtual environment and give it a name, such as
glearn_env
conda create --name glearn_env -y
The command
conda info --envs
shows the list of all environments. The current environment is marked by an asterisk in the list, which should be the default environment at this stage. In the next step, we will change the current environment to the one we created.Activate the new environment
source activate glearn_env
Install
glearn
with any of the above methods. For instance:conda install -c s-ameli glearn
Then, use the package in this environment.
To exit from the environment
conda deactivate