search
Search
Login
Math ML Join our weekly DS/ML newsletter
menu
menu search toc more_vert
Robocat
Guest 0reps
Thanks for the thanks!
close
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
help Ask a question
Share on Twitter
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
icon_star
Doc Search
icon_star
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to
A
A
brightness_medium
share
arrow_backShare
Twitter
Facebook
check_circle
Mark as learned
thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings

Creating a new Conda environment

Environment Setup
chevron_right
Anaconda
schedule Jul 1, 2022
Last updated
local_offer Python
Tags

Creating new environment

To create a Conda environment, run the following in Terminal:

$ conda create --name my_env python

Here, we are naming our Conda environment my_env, and configuring the environment for Python development.

Note the following:

  • if an environment called my_env exists, then it would ask you whether or not you want to overwrite it.

Specifying Python version

By default, the new Conda environment will use the same version of Python as the base environment. We can specify which version to use by:

$ conda create --name my_env python=3.8

Specifying which libraries to include

By default, new Conda environments come with the core libraries such as pip and openssl. To include other packages such as flask:

$ conda create --name my_env python flask

You can actually remove python here since flask obviously depends on python, and so Conda will also assume Python automatically.

As we've done previously, we can also specify which version of the library we wish to include:

$ conda create --name my_env python flask=1.1.1

Location of new environment

When you run the create command, the path of the new environment should be shown on screen. In our case, the path is as follows:

environment location: /Users/SkyTowner/opt/anaconda3/envs/my_env

We see that Conda places our environment into a directory called envs. You can specify the location by adding the --prefix flag:

$ conda create --prefix /path/of/new/environment

Activating the environment

See a list of environments

To see all your Conda environments:

$ conda info --envs
# conda environments:
#
base * /Users/SkyTowner/opt/anaconda3
my_env /Users/SkyTowner/opt/anaconda3/envs/my_env

Here, the * indicates that base is the currently active environment.

Activating the environment

To activate the Conda environment:

$ conda activate my_env

After you run the command, you should see (my_env) appended at the front:

(my_env) Macbook:~ SkyTowner$

Deactivating the environment

To deactivate the Conda environment:

$ conda deactivate my_env

This brings us back to the base or root environment.

Installing new packages within the new environment

With the newly created environment active, call conda install to install a new package:

(my_env) MacBook:~ SkyTowner$ conda install jsonpath
## Package Plan ##
environment location: /Users/TraverseTowner/opt/anaconda3/envs/my_env
...

Since we're in my_env, Conda installs the package jsonpath under the my_env directory. In our case, jsonpath is installed in the following directory by default:

/Users/SkyTowner/opt/anaconda3/envs/my_env/lib/python3.8/site-packages

Note that if you did not have an environment active, that is, if you were in the base environment, new packages would be installed in the pkgs directory instead.

mail
Join our newsletter for updates on new DS/ML comprehensive guides (spam-free)
robocat
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Ask a question or leave a feedback...