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#

  1. Install virtualenv:

    python -m pip install virtualenv
    
  2. Create a virtual environment and give it a name, such as glearn_env

    python -m virtualenv glearn_env
    
  3. Activate python in the new environment

    source glearn_env/bin/activate
    
  4. Install glearn package with any of the above methods. For instance:

    python -m pip install glearn
    

    Then, use the package in this environment.

  5. To exit from the environment

    deactivate
    

2.2. Install in conda Environment#

In the followings, it is assumed anaconda (or miniconda) is installed.

  1. 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
    
  2. 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.

  3. Activate the new environment

    source activate glearn_env
    
  4. Install glearn with any of the above methods. For instance:

    conda install -c s-ameli glearn
    

    Then, use the package in this environment.

  5. To exit from the environment

    conda deactivate