Install Anaconda env

Nov 4, 2018 2 min read
Install Anaconda env

Install

Install Anaconda for your operating system.

Create a virtual environment for your project

The default directory for conda env is:
macOS: /Users/yourName/anaconda3/envs
Windows: /c/Users/userName/AppData/Local/Continuum/anaconda3/envs

Create env: Either use the GUI app or con the terminal: conda create -n vEnv python or conda create -n -f=/path/to/environment.yml python=x.x
Activate it on macOS and Linux: source activate yourenvname
Deactivate your virtual environment: source deactivate
Delete: conda remove -n yourenvname -all

Show all env: conda env list
List packages in an environment:

  • If the environment is not activated, in your Terminal window or an Anaconda Prompt, run: conda list -n myenv
  • If the environment is activated, in your Terminal window or an Anaconda Prompt, run: conda list

Install additional Python packages to a virtual environment: conda install -n yourenvname [package]

Sharing an environment

You may want to share your environment with someone else—for example, so they can re-create a test that you have done. To allow them to quickly reproduce your environment, with all of its packages and versions, give them a copy of your environment.yml file.

Exporting the environment file

NOTE: If you already have an environment.yml file in your current directory, it will be overwritten during this task.

  1. Activate the environment to export: source activate myenv
  2. Export your active environment to a new file: conda env export > environment.yml NOTE: This file handles both the environment’s pip packages and conda packages.
  3. Email or copy the exported environment.yml file to the other person.

Building identical conda environments

  1. Run conda list --explicit to produce a spec list of packages installed
  2. To create this spec list as a file in the current working directory, run: conda list --explicit > spec-file.txt

Note: An explicit spec file is not usually cross platform, and therefore has a comment at the top such as # platform: osx-64 showing the platform where it was created. This platform is the one where this spec file is known to work. On other platforms, the packages specified might not be available or dependencies might be missing for some of the key packages already in the spec.

To use the spec file to create an identical environment on the same machine or another machine: conda create --name myenv --file spec-file.txt

To use the spec file to install its listed packages into an existing environment: conda install --name myenv --file spec-file.txt

Using pip in an environment

To use pip in your environment, in your Terminal window or an Anaconda Prompt, run:

conda install -n myenv pip
source activate myenv
pip <pip_subcommand>

Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.