0

I'm using default version of Python(2.7) on Macbook Pro with High Sierra. I have installed default version of tensorflow, which is 1.9, with this command:

pip -V
>>>pip 18.0 from /usr/local/lib/python2.7/site-packages/pip-18.0-py2.7.egg/pip (python 2.7)

pip install tensorflow
pip list

>>>tensorflow 1.9.0

Then I fire up python:

python
Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Then I try to import tensorflow and get this error:

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
>>>

I have tried to follow the instructions multiple times with no success. I'd appreciate any help. Thanks.

7
  • What are you using to run your code? idle?, spyder? pycharm? terminal? ... Commented Aug 2, 2018 at 17:55
  • I'm using mac terminal. Commented Aug 2, 2018 at 20:49
  • Did you use Anaconda to load a version of python? Commented Aug 2, 2018 at 21:32
  • Why use the ancient Python 2.7 that Apple ships when Python 3 has been out 10 years? Commented Aug 2, 2018 at 22:37
  • @jmh I have Anaconda on my machine and it works fine. I need non-anaconda environment for connectivity between Python and R. Commented Aug 3, 2018 at 5:38

1 Answer 1

1

When you installed tensorflow it might be associated with a different version of python. I suggest you run in virtual environments. Create a virtual environment and activate it. Then once its activated run pip install tensorflow and then try to run your code with your virtual environment still activated.

This link has a much better description of why you need virtual environments and how you install them.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the input. It works, it turns out the problem was somewhere else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.