Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow pip installation issue: cannot import name 'descriptor'

Tags:

tensorflow

I'm seeing the following error when installing TensorFlow:

ImportError: Traceback (most recent call last):
File ".../graph_pb2.py", line 6, in 
from google.protobuf import descriptor as _descriptor
ImportError: cannot import name 'descriptor'
like image 358
Barry Rosenberg Avatar asked Feb 02 '17 15:02

Barry Rosenberg


3 Answers

This error signals a mismatch between protobuf and TensorFlow versions.

Take the following steps to fix this error:

  1. Uninstall TensorFlow.
  2. Uninstall protobuf (if protobuf is installed).
  3. Reinstall TensorFlow, which will also install the correct protobuf dependency.
like image 73
Barry Rosenberg Avatar answered Oct 08 '22 23:10

Barry Rosenberg


I faced the similar issue, after trial and error, I used the below logic to run the program:

pip install --upgrade --no-deps --force-reinstall tensorflow

This will make sure to uninstall and reinstall the program from fresh. It works!

like image 45
Prashanth R Avatar answered Oct 08 '22 22:10

Prashanth R


I would be extra careful before uninstalling/reinstalling other packages such as protobuf. What I think would most likely be the issue is difference in versions. As of writing this, the most recent release of python is 3.7 while tensorflow is only compatible up to 3.6.

If you're using a 3rd party distribution like Anaconda, this can get hidden from you. In this case I would recommend creating a new environment in Anaconda, with python 3.6 and then installing tensorflow: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python

like image 37
MacNutter Avatar answered Oct 09 '22 00:10

MacNutter