Installing conda
There are different flavors of conda: Anaconda (which is not open source), Miniconda, and Miniforge. I do not recommend using Anaconda unless you absolutely need some of the additional packages it comes with. Aside from being a large install, it is not technically open source, which can lead to some unexpected licensing issues.
Here I provide instructions for installing Miniconda
Step 1: Install Miniconda
Mac/Linux/Windows Subsystem for Linux (WSL)
Open a terminal in VS Code by clicking “Terminal” -> “New Terminal”.
In the terminal window, type:
cdThen hit ENTER.
Follow the instructions Quickstart install instructions on the Miniconda website. For WSL, select “Linux”.
Windows
Download the Miniconda installer for Windows. Click the Downlad button under “Miniconda Installers”, not the one under “Distribution Installers”.
Run the installer by double-clicking on the downloaded file and follow the steps below.
Click “Run”.
Click on “Next”.
Click on “I agree”.
Select “Just me” and click on “Next”.
Click “Next” to install to the default destination folder.
WarningIf you had tried to install miniconda previously, you may get an error that says “Directory … is not empty, please choose a different location.” Do not choose a different location. Instead, click “OK”, then rename the previous miniconda3 directory. You can do that by going to VS Code, opening a new terminal window (click “Terminal” -> “New Terminal”), and entering the following (hit ENTER after each line):
cd mv miniconda3 miniconda3-oldThen go back to the Miniconda installer and click “Next”.
Check the option for “Add Anaconda to my PATH environment variable” and check the option for “Register Anaconda as my default Python 3.x”.
- Note that even though the installation is for Miniconda, the installer uses the word Anaconda in these options.
- You will also see a message in red text that selecting “Add Anaconda to my PATH environment variable” is not recommended; continue with this selection to make using conda easier in Git Bash. If you have questions or concerns, please contact your instructor.
Click on “Install”.
When the install is complete, Click on “Next”.
Click on “Finish”.
Open a new terminal window in VS Code by clicking “Terminal” -> “New Terminal”.
Type the following command to initialize conda:
conda init bashOpen a new terminal window in VS Code by either hitting the “+” key next to “bash” in the upper left of the terminal window, or by cliking “Terminal” -> “New Terminal”. If conda installed successfullly, you should see
(base)appear next to or above your command prompt.
Step 2: Create a conda environment and test it in VS Code
In the bash terminal window in VS Code (make sure it says
(base)to the left of or above the prompt), type:conda create -n ist356 -c conda-forge -y python=3.11 ipykernelThen hit ENTER.
WarningThe first time you run conda, you may get an error about Terms of Service not being accepted for certain channels. Accept the TOS for those channels by running the commands listed. For example, if one of the channels is
https://repo.anaconda.com/pkgs/main, copy and paste the command into the terminal:conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/mainFollowed by hitting ENTER (to execute a command in the terminal, you hit ENTER after typing/pasting it in). You’ll need to do this for each of the channels listed.
Once you have accepted the TOS for all the channels, run the
conda createcommand above again.Check to ensure your environment works:
Click File -> “New File…”
In the drop down menu, select “Jupyter Notebook”.
Click “Select Kernel” on the right then type “ist356”.
In the first cell, type:
print("hello world!")Hit the run button on the left or type SHIFT + ENTER to execute the code. You should get back “hello world!”.
Close the ipynb file (you may optionally save it; if you do, be sure to call it something other then “Untitled.ipynb”, maybe “hello.ipynb” instead).