Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named __future__

I have error as No module named __future__. I use tensorflow and it has Python2.7. Once I run a program, I got error as shown below.

import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/coie/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 19, in <module>
    from __future__ import absolute_import
ImportError: No module named __future__

How to install future into tensorflow's Python?

like image 667
batuman Avatar asked Nov 08 '16 04:11

batuman


1 Answers

Check that your Python modules are executable.

In your /PATH/Python-2.7.x/Lib should be all your modules, incl. future

If you don't have the above, re-install Python.

If you do, run ls -l which will show you the permissions associated with the modules in the first column. *.py should read -rwxr-xr-x. If it reads -rw-r--r-- instead, the modules can't be imported or executed when they are called in your script. To fix this, change permissions with sudo chmod +x *.py.

Also, you need to check that python knows where to look for these modules. You can check this with echo $PYTHONPATH which should show you the path to you Lib directory. If not, set via export PYTHONPATH=$PYTHONPATH:/PATH/Python-2.7.13/Lib. Also check out explanation and links in the answer to the following question: https://askubuntu.com/questions/250929/pythonpath-environment-variable

like image 63
hydra_hamster Avatar answered Oct 23 '22 19:10

hydra_hamster