Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow successfully installs on mac but gets ImportError on copyreg when used [closed]

After successfully pip install, importing the tensorflow library fails.

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 13, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/Library/Python/2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 8, in <module>
    from google.protobuf import reflection as _reflection
  File "/Library/Python/2.7/site-packages/google/protobuf/reflection.py", line 58, in <module>
    from google.protobuf.internal import python_message as message_impl
  File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 59, in <module>
    import six.moves.copyreg as copyreg
ImportError: No module named copyreg
like image 642
feng Avatar asked Nov 10 '15 02:11

feng


3 Answers

You can upgrade to six-1.10.x using

easy_install -U six

This will upgrade the current version of six from 1.4 to 1.10.x, that is required by tensorflow.

like image 77
Abhilash Panigrahi Avatar answered Nov 13 '22 07:11

Abhilash Panigrahi


Solution: TensorFlow depends on protobuf which require six-1.10.0. Apple's default python environment has six-1.4.1 and may be difficult to upgrade. So we recommend either installing a separate copy of python via homebrew:

brew install python

or building / using TensorFlow within virtualenv as described above.

like image 20
Evan Cater Avatar answered Nov 13 '22 06:11

Evan Cater


copyreg is a python3 function that is available in the six module in python2.x, see https://docs.python.org/2/library/copy_reg.html#module-copy_reg

To get copyreg, you have to install six:

pip install -U six

(Note: In python2, you access can either access the function with (i) six.copy_reg or when a module is imported with six.moves.*, it keeps the python3 syntax, i.e. six.moves.copyreg)

like image 1
alvas Avatar answered Nov 13 '22 07:11

alvas