2

I found a great Medium article on creating a new neural network architecture that I wanted to try out. Of course, I get to the training part, and things start to fail.

I can't import TensorFlow. Whenever I do, I get the error

Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin   File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow   File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
    from tensorflow.python.platform import self_check ImportError: No module named 'tensorflow.python.platform'

Well, I looked at this which suggested importing in a different folder which did not work. I also tried exporting the PYTHONPATH variable, set to PYTHONPATH="/home/London/.virtualenvs/worldmodels/lib/python3.5/site-packages" and PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages/" and PYTHONPATH="/usr/local/lib/python2.7/dist-packages/", all to no avail.

This one seemed to be a language issue, which shouldn't be my problem (and if it is, I don't know what they did to fix it.)

This one gave the same folder changing advice. This one seemed to be an issue with someone's command, not just trying to import it. And this one again suggests the setting PYTHONPATH. (And yes, I did see this one, but both the question and answer quality are lacking.)

Any ideas as to what I could do to get TensorFlow up and running?

(Maybe using a different install process than just pip? I have already tried installing by running sudo pip install tensorflow. I would still like to be able to use it with the Medium tutorial though.)

Pro Q
  • 4,391
  • 4
  • 43
  • 92
  • Are you using a virtual env for this python code? If not, then could you tell me the output for the commands `which python` and `whereis python` – Haris Nadeem Jun 09 '18 at 07:58
  • 1
    WSL is still experimental. Why not install native Windows Python instead? – rustyx Jun 09 '18 at 08:02
  • @rustyx because the tutorial has a bunch of Ubuntu commands that I didn't know how to do in Windows. (I do have native windows Python installed.) – Pro Q Jun 09 '18 at 08:05
  • @HarisNadeem I am using both virtualenv and virtualenvwrapper. In case it still helps: `which python` gives `/home/myusername/.virtualenvs/worldmodels/bin/python` – Pro Q Jun 09 '18 at 08:08
  • `whereis python` gives `python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python2.7-config /usr/bin/python3.5 /usr/bin/python3.5-config /usr/bin/python3.5m /usr/bin/python3.5m-config /usr/lib/python2.7 /usr/lib/python3.5 /etc/python /etc/python2.7 /etc/python3.5 /usr/local/lib/python2.7 /usr/local/lib/python3.5 /usr/include/python2.7 /usr/include/python3.5 /usr/include/python3.5m /usr/share/python /home/myusername/.virtualenvs/worldmodels/bin/python /home/myusername/.virtualenvs/worldmodels/bin/python3.5`... to be continued – Pro Q Jun 09 '18 at 08:08
  • `/mnt/c/Users/myusername/AppData/Local/Programs/Python/Python36-32/python.exe /mnt/c/Users/myusername/AppData/Local/Programs/Python/Python36-32/python3.dll /mnt/c/Users/myusername/AppData/Local/Programs/Python/Python36-32/python36.dll /usr/share/man/man1/python.1.gz` – Pro Q Jun 09 '18 at 08:09
  • and if you type `/home/myusername/.virtualenvs/worldmodels/bin/python -m pip freeze` does it list tensorflow? – Haris Nadeem Jun 09 '18 at 08:25
  • I do agree with @rustyx, why not just do it via VMWare? – Haris Nadeem Jun 09 '18 at 08:26
  • Which version of Tensorflow do you have? – Dr. Snoopy Jun 09 '18 at 09:21
  • @HarisNadeem, MatiasVeldenegro: tensorflow==1.7.0 – Pro Q Jun 09 '18 at 16:44
  • @HarisNadeem I need the max amount of memory I can have to be running these projects, and virtual machines I've found run slow and are a slight hassle to set up. I'd rather do it just right on my computer where all my commands and things I'm used to are right here. – Pro Q Jun 09 '18 at 16:46
  • 1
    Can you try updating the version with `sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.7.0-cp34-cp34m-linux_x86_64.whl`. Latest is 1.8 but this will update it to the latest 1.7 hopefully. Source : https://www.tensorflow.org/install/install_linux – Haris Nadeem Jun 09 '18 at 19:33
  • @HarisNadeem I got back `tensorflow-1.7.0-cp34-cp34m-linux_x86_64.whl is not a supported wheel on this platform.` – Pro Q Jun 09 '18 at 23:40
  • I also get back `You are using pip version 8.1.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.` but when I try to upgrade it tells me `Requirement already up-to-date: pip in /home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages (10.0.1)` which is odd. – Pro Q Jun 09 '18 at 23:46
  • Oh weird, okay, `sudo pip` is version 8, but just `pip` is version 10. Something very odd is going on here. I'm working on installing Tensorflow 1.8 using `pip`. – Pro Q Jun 09 '18 at 23:57
  • Alright, it looks like doing `pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl` worked. Thank you! – Pro Q Jun 09 '18 at 23:59

2 Answers2

2

The issue was resolved by typing

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl

@ProQ does a better job explaining how they were able to resolve it!

Pro Q
  • 4,391
  • 4
  • 43
  • 92
Haris Nadeem
  • 1,322
  • 11
  • 24
1

It looks like there was some other weird stuff going on. The biggest thing I noticed that was odd is that sudo pip --version gave a different version than just pip --version.

Doing pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl upgraded and allowed me to import tensorflow. (Note that doing sudo pip did not work.)

Thank you @HarisNadeem for the solution and for helping diagnose the issue!

Pro Q
  • 4,391
  • 4
  • 43
  • 92