How to install Tensorflow in an Anaconda virtual environment – Mac

So I have Anaconda installed and wanted to install TensorFlow as well (I’m using PyCharm):

I tried installing TensorFlow with Conda as per official doc:

  • conda create -n tensorflow pip python=3.6
  • source activate tensorflow
  • pip install –ignore-installed –upgrade

However when creating a new virtual environment in PyCharm you need to make sure TensorFlow is installed as well in there, to do so simple do (after you have created your project {i.e. tf_basics} in PyCharm):

  • source activate tf_basics
  • pip install –ignore-installed –upgrade $URL_THAT_MAKES_SENSE I used:
    • pip install –ignore-installed –upgrade
    • Tip: you may get annoying messages like: “Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA”
    • Installing the proper tf version should fix it, take a look here for more info:
    • Or just do…
      import os
      os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘2’

To test your virtual env is running TensorFlow you can run TensorFlow hello world:

import tensorflow as tf
hello = tf.constant(‘Hello, TensorFlow!’)
sess = tf.Session()



Leave a Reply