Working With Virtual Environments In Python Using Anaconda’s CLI

In order to help with environment issues, using virtual environments can be a lifesaver. Not only that, it allows your projects to only have the packages it needs and saves space on deployment websites like heroku, aws, and more. In this article, I’ll break down how to use Anaconda’s Command Line Interface (CLI) to create and work with virtual environments.

How To Install Anaconda’s CLI

I’m not going to reinvent the wheel. Anaconda has a great resource here that shows how to install it on multiple operating systems.

Using Anaconda

Navigate to Anaconda Prompt (like the image below) and open it up.

Once it’s open, you can verify the version using the code below.

If you need to update a version, you can use the code below

Creating a virtual environment

Once your CLI is all setup, navigate to the directory you’re working on code, and use the following code to create a new environment. (Note: anything in <> is what you will replace with what you want it to be)

After a minute or so, it will be created. You can activate this environment and deactivate it by using the two different lines of code below

If you forgot the names of your environments, you can use the code below to give a list of all of them

Lastly, if you need to delete an enviornment, use the code below to do that

Additional Resources

Cheetsheet

Getting started with conda

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store