I started off with Tensorflow recently. But before I could begin programming, I needed to have the necessary tools and environment set up on my MacBook Pro. I was already using the Anaconda Python 2.7.x distribution and wanted to keep some of my older projects in working condition and avoid the complications of multiple Python installations.
So, here are the steps I followed to setup an environment that had Python 3.6.x. (Steps 2 and 3 are not necessary. I did it to update my base Python 2.7.x to the latest and greatest releases)
Open up a terminal
Update conda
conda update conda
Update anaconda
conda update anaconda
Create a new environment
conda create -n tensorflow -python=3.6 anaconda
Let's understand what this command does:
conda create
is the instruction to create an enviromentThe argument
-n
followed by the valuetensorflow
indicates that the name of the environment istensorflow
The argument
-python
with the value3.6
indicates the Python version that will be used for thetensorflow
environment.Environment creation might take a while; relax. Once it's completed, use
source activate tensorflow
to activate the environment. One may check that the prompt has changed to something like(tensorflow) MacBook Pro$
. To deactivate the environment, usesource deactivate
.Now that the environment is ready, the tensorflow packages could be installed - I used the
pip
command to perform the installation
pip install --ignore-installed --upgrade tensorflow
The last step will take a while because all dependencies will be downloaded and installed. Usually this is quite easy and goes through without any errors. However, if there are errors, a good place to start off would be the Common installation problems section at https://www.tensorflow.org/install