Anaconda allows us to create different instances of Python called environments. After installing Anaconda, we have a single core environment called base.
We see this environment name whenever we open Anaconda prompt.
Nothing is stopping us from installing new Python packages (such as Pandas/TensorFlow) within the base environment. However, it is recommended to instead use different virtual environments either for different projects or use-cases.
Our use case is machine learning, and so we will create a new environment for this using the command
conda create -n <env-name> python=<python-version> anaconda, like so:
A list of packages will be displayed, and conda will ask if we want to proceed — we type
y + [ENTER] to continue.
After everything has been installed, we will be able to switch to our new environment by typing
conda activate <env-name>:
We should see that
(base) has been replaced with
(mlenv) — this means we are now working from inside our new virtual environment. So we can get started with installing all of the packages we need for ML.
For most packages, it makes sense to attempt a
conda install <package-name> — if this doesn’t work, try
pip install <package-name>.
A few essentials that we almost always need are Numpy, Pandas, and Matplotlib. We can install them all using
We can install TensorFlow easily with
conda install tensorflow:
Conda does not recognize the most recent versions of the Transformers library, so we instead install that with
pip install transformers:
And finally, we have PyTorch. PyTorch is a slightly more complex installation — but made easy by accessing the PyTorch installation guide here.
We will need to specify our OS, package manager (Conda), language (Python), and whether we have CUDA or not.