Setting up Anaconda for Python Development
How to set up Anaconda on Windows
Configuring Anaconda for Windows 10
Motivations
Why Anaconda? Well, it allows you to install different (and potentially conflicting) version of Python libraries on your computer without the risk of it breaking your base Python installation.
Installing Anaconda
- Download miniconda from anaconda.com for the version of Python and your particular operating system.
- Follow the installer instructions. I installed it with the following settings:
- Install for all users
- Install location:
C:\ProgramData\anaconda3 - Add to PATH
- Register as default Python installation
Adding Anaconda to PATH
If you didn’t choose the
Add to Pathoption above, complete the following steps:
- Edit the PATH system variable:
- Windows Key -> System Environment Variables
- Select Environmental Variables -> PATH -> edit
- Depending on whether you installed for a single user or for all users, add the following entry in your environment variable:
%USERPROFILE%\Anaconda3\condabinfor single userC:\ProgramData\Anaconda3\condabinfor all users
- Test that it works by opening up a new Command Prompt window and run the
conda --versioncommand
Allowing Conda to work in Git Bash
- Open up Git Bash and run
cd C:\ProgramData\anaconda3\etc\profile.d(navigate to where your Anaconda3 installation destination is) - Running
lsshould show two files - conda.csh and conda.sh - Run the following command to add it to your
.bashrc
# If there are no spaces in your path to conda.sh:
echo ". ${PWD}/conda.sh" >> ~/.bashrc
# If there __are__ spaces in your path to conda.sh:
echo ". '${PWD}'/conda.sh" >> ~/.bashrc
- Run
cat ~/.bashrcand check that the following line has been added:. /c/ProgramData/anaconda3/etc/profile.d/conda.sh - Restart your terminal and run
conda --versionto test that it works
Creating Environments in Anaconda
Now that everything is set up, we can create environments in Anaconda using the following command:
conda create --name $envName python=$pyVersion
This command can also be extended, for example to install PyTorch:
conda install pytorch torchvision torchaudio cpuonly -c pytorch