BYU logo Computer Science

Creating a Conda Environment

A conda environment includes the Python code that includes everything a program needs to run properly. Think of it like this — a proper study environment for you might include a desk, headphones, and lo-fi music. If you don’t have these things, you might not perform well. For a Python program to run effectively, it also needs an environment that includes all the necssary things for it to run.

Conda is a package manager, which is similar to an app store. Conda will create an environment for you, which means installing code and manage updates for that code. It gets all of this software for free (legally!) from the Internet.

Choose a Terminal

Windows terminal

Use the search bar to open a terminal. It needs to have both “Anaconda” and “Powershell” in its name.

Mac terminal

Quit the Terminal app, if it is already open.

Use Launchpad or Spotlight search to open the Terminal app.

All terminals: create conda envirionment

Copy and paste the following two commands. If either of these two commands prompts you with a yes or no, generally denoted with a [y/n], press “y” and then enter to continue.

This first command creates an environment called cs110 that has the pytest package in it:

conda create -n cs110 pytest

This command will likely prompt you to accept terms and conditions. When it does so, simply press “a” and then enter to accept. Generally, it will prompt you 3 times for this, each time press “a” and enter. If it does not prompt you or prompts you less than 3 times before proceeding to install, then continue with the rest of the instructions.

This second command runs an installer called pip inside the cs110 environment. Pip is useful for creating your own packages and installing less well-known packages, like byu-pytest-utils and byubit:

conda run -n cs110 python -m pip install -U byu_pytest_utils byubit