11

I have installed tensorflow following the guide at the website. Tensorflow code runs perfectly, I have also installed tflearn. Problem is whenever I am trying to import tflearn it says "ImportError: No module named 'tflearn'" but tflearn is there in the site-packages directory

I have an Anaconda installation and a Conda environment for running tensorflow code

Sharthak Ghosh
  • 576
  • 1
  • 9
  • 22
  • Which site-package directory is `tflearn` in? Is it in the tensorflow virtual environment's site-package directory? Also did you run into any installation error when you were installing `tflearn`? – Zhongyu Kuang Nov 30 '16 at 06:04
  • I checked using pip show tensorflow and pip show tflearn, this is what I got tflearn location : -/home/sharthakghosh/anaconda3/lib/python3.5/site-packages tensorflow location :- /home/sharthakghosh/anaconda3/envs/tensorflow/lib/python3.5/site-packages – Sharthak Ghosh Nov 30 '16 at 07:06

4 Answers4

10

Seems to be an Anaconda issue.

pip install tflearn 

was throwing parse errors. This worked for me: open Anaconda prompt

conda install pip
pip install tflearn
caramelslice
  • 359
  • 1
  • 4
  • 16
4

Thanks a lot, it worked. I first uninstalled tflearn, then activated the tensorflow environment and simply did a pip install tflearn. Then installed h5py and scipy after that. It works perfectly now. Thanks to Zhongyu Kuang for pointing out the difference between the environments.

Sujit
  • 143
  • 2
  • 13
Sharthak Ghosh
  • 576
  • 1
  • 9
  • 22
1

This solution might look very long and wierd, but trust me it doesnt throw any errors/ exceptions. It works perfect.

You could also try doing by activating the virtual env,

For example in my case, I have different environment where I use to work around all ML, NLP code here.

Activate your virtual env first,

$ source activate myML-env

which will open new environment, like below

(myML-env)$

Now within this env, hit enter after this below command to install your tflearn package only within this environment.

(myML-env)$ pip install tflearn

Don't panic if tflearn works well even in python 3.X. (NOTE: Make sure you have tensorflow already installed in this Virtual environment, if not use the same command with the slight change [pip install tensorflow])

Now follow the below command to deactivate the current virtual env,

$ source deactivate myML-env

Now open your Anaconda >> Environments >> Select myML-env, now open your spyder application from this environment.

Sundar Gsv
  • 627
  • 7
  • 7
0

I also had the same problem when I did the following installations conda install scipy h5py pip install tensorflow pip install tflearn

I had a warning that a package needed Cython but it wasn't installed. So to solve the problem, I did: pip install cython pip install tensorflow conda install scipy h5py pip install tflearn