2

I've installed anaconda (python3.6) and installed tensorflow as mentioned here:

conda create -n tensorflow python=3.5

and activated tensorflow, now I want to run example codes in sublime text3 and I can't import tensorflow. I've tried the same in Spyder with the same result.

 import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

any idea what I'm doing wrong here? (the code is definitely correct)

kmario23
  • 57,311
  • 13
  • 161
  • 150
Engine
  • 5,360
  • 18
  • 84
  • 162

1 Answers1

7

What you are doing here is creating a virtual environment named tensorflow.

The correct way to do it is: (in the same order)

$ conda create --name yourenv python=3.5 anaconda
$ source activate yourenv
$ conda install -n yourenv tensorflow

Then, from the ipython terminal do:

import tensorflow as tf

To make things work in SublimeText editor, please follow the steps as documented here: sublimeText and VirtualEnv

Basically, you need to add the following line in the project settings.

"settings": {
    "python_interpreter": "/home/user/.virtualenvs/example/bin/python"
}

For people using Anaconda distribution, it's little bit different.

"settings": {
        "python_interpreter": "/home/user/anaconda3/envs/myenv/bin/python"
    }
Community
  • 1
  • 1
kmario23
  • 57,311
  • 13
  • 161
  • 150