Miniconda
Miniconda (and Anaconda, too) comes with a complete Python distribution that lets
you create isolated environments that don’t affect anything else.
conda
is the tool that manages these environments.
We have tried to collect all tools and libraries which we will use and
demonstrate during a CodeRefinery workshop into an environment.yml
file so
that you can create a new and independent environment with all the necessary
packages so that it will not affect what you use for your daily programming or
projects. This comes at the last step (Creating the Conda environment for CodeRefinery workshops).
To enable creating the environment mentioned above, we need you to have a relatively new version of Conda.
First you need to install Miniconda.
Then, in the next page, you set up the CodeRefinery environment.
Why not Anaconda?
Anaconda is more convenient at the beginning since it provides most packages out of the box. However, in the long term we recommend to have a minimal base system and install packages into project-specific environments and for this, Miniconda is a better choice. For our workshops we therefore recommend Miniconda to prepare you for the long term and to start with good practices right from the start. Another benefit is the smaller install size and time.
Installing Miniconda
If you don’t have Miniconda or Anaconda at all
From the Miniconda installer page, download Miniconda3 installer with the latest Python version.
Follow regular installation instructions for your operating system.
Make sure selecting:
installing just for you
“Add miniconda3 to my PATH environment variable”
“Register Miniconda3 as my default Python 3.9”
If you have Miniconda or Anaconda but you have not used it for a long time
If you have only old Anaconda, but not Miniconda, then install Miniconda3 following the instruction above.
If you have old Miniconda (no matter if you have Anaconda or not), follow the instruction below and upgrade Conda. Please replace
anaconda
withconda
in the instruction for Windows and macOS:
If you have Anaconda and you are using it regularly
You can use your existing Anaconda install and create the Coderefinery environment as the next page says.
Or, you can probably go through most of the workshop and most of the packages that we will need already are part of Anaconda. If some package is missing, you can then fetch it with the Anaconda Navigator. One disadvantage of using Anaconda is however, that you are more likely to install everything into the base environment whereas the Miniconda approach suggests to use more isolated environments without modifying your base environment.
Setting path to Conda from your terminal shell
In CodeRefinery workshops, we need the Bash/Zsh shell terminal to be able to “see” and run a couple of conda-installed tools and libraries.
Prerequisites
You have Bash and relatively new version of Conda installed in your computer.
You get an error message like
conda command not found
whey you typeconda --version
in your shell terminal.After opening a new terminal and typing
conda --help
you still getconda command not found
.
Go to the Miniconda3 (or if you have a relatively new Anaconda, then Anaconda3) folder. You can find it by serching from File Explorer search bar.
Navigate to
etc
folder, and then toprofile.d
folder. You will find theconda.sh
file.In the folder, right click and choose “Git Bash Here”. You should be able to see the path to this folder in the Git Bash (something like ~/Miniconda3/etc/profile.d).
Run the following command (type the following and enter):
$ echo ". '${PWD}'/conda.sh" >> ~/.bashrc
Close Git Bash and reopen it.
Verify that now Git Bash can “see” conda by running
conda --version
After step 5 you may see this warning but this is nothing to worry about and will not show up the next time you open Git Bash:
WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.
This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be created for you.
Reference: “Setting Up Conda in Git Bash”, Sep 2020, at Codecademy Forums
Open a terminal window.
Find the
.zshrc
file (or.bash_profile
if your shell is Bash) which should be located in your home directory (/User/your-user-name)Navigate to the directory where
.zshrc
is located (or.bash_profile
if your shell is Bash).Add the following in
.zshrc
file (or.bash_profile
):
$ export PATH="$HOME/miniconda3/bin:$PATH"
Open a terminal window.
Run this command which will append to your
.bashrc
file (adapt the path if Miniconda has been installed to a different place):
$ echo 'source $HOME/miniconda3/bin/activate' >> ~/.bashrc
If you prefer not to edit your .bashrc
, you can also run this command after opening your terminal (each time you open one)
and it will bring all conda
commands “into view”:
$ source $HOME/miniconda3/bin/activate
Conda path verification
The following command should return something in the terminal you plan on using.
$ conda --version
How to uninstall/remove Conda
If you wish to remove Conda again after the workshop, here is how: