简体   繁体   中英

Cannot install Tensorflow with Pycharm because of Protobuf error

I installed Pycharm for Windows 10

pip install tensorflow went fine without errors

When trying to run a simple project

    # Import `tensorflow`
import tensorflow as tf

# Initialize two constants
x1 = tf.constant([1,2,3,4])
x2 = tf.constant([5,6,7,8])

# Multiply
result = tf.multiply(x1, x2)

# Print the result
print(result)

I get the error message

Traceback (most recent call last):
  File "C:/Users//PycharmProjects/RiffRam/RiffRam.py", line 2, in <module>
    import tensorflow as tf
  File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
  File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

Can somebody please tell me how I can get a working installation of Tensorflow, it seems that all the versions are mismatched and pip makes no attempt to install correct versions of each package. I don't care if its outdated.

What commands do I need to type in to get a working stable version from a clean installation of Pycharm so that the code above would run? Thank you

I got it

pip install --upgrade --force-reinstall setuptools==39.1.0
pip install --upgrade --force-reinstall protobuf==3.6.0
pip install --upgrade --force-reinstall tensorflow==1.11

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM