【问题标题】:No module named 'tensorflow.python.platform'没有名为“tensorflow.python.platform”的模块
【发布时间】:2019-11-03 12:01:04
【问题描述】:

我正在使用 python3 并使用以下方法安装了 tensorflow-gpu:

pip3 install tensorflow-gpu==1.13.1

并检查了它是由以下人员安装的:

pip3 show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.13.1
Summary: TensorFlow is an open source machine learning framework for 
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/lib64/python3.6/site-packages
Requires: tensorflow-estimator, keras-applications, termcolor, absl-py, six, 
astor, protobuf, wheel, keras-preprocessing, gast, grpcio, numpy, 
tensorboard
Required-by:

但是当我执行以下操作时,它会给我一个错误:

user:/home/mydirectory # python3
Python 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, 
in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: 
disable=unused-import
  File "/usr/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
    from tensorflow.python.platform import self_check
ModuleNotFoundError: No module named 'tensorflow.python.platform'

我从错误中看到它在目录中寻找 tensorflow

/usr/lib/python3.6/site-packages/tensorflow

但是 pip 表明它安装在

/usr/lib64/python3.6/site-packages

我该如何解决这个问题?

【问题讨论】:

  • 在这种情况下,user:/home/mydirectory # 中的 # 是指 root 用户吗?如果是这样,与您的用户相比,root 用户的配置可能不同。
  • 您使用的是哪个操作系统?请同时指定版本?
  • 会不会是您的发行版最近删除了符号链接/{usr,}/lib -&gt; /{usr,}/lib64 并且迁移不顺利? /lib 应该只适用于 32 位的东西。能否也将python3.6 -m site 的输出添加到问题中?
  • @Harry Boy 请尝试使用 root 或 sudo 安装。然后尝试 pip3 --version shekh@shekh:~$ pip3 --version pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5) shekh@shekh:~$ python3 Python 3.5.2 (默认,11 月12 2018, 13:43:14) [GCC 5.4.0 20160609] 在 linux 上键入“帮助”、“版权”、“信用”或“许可证”以获取更多信息。 >>>

标签: linux python-3.x tensorflow pip opensuse


【解决方案1】:
Please follow below steps..
0) please login with root permission or sudo and write this command in terminal 

1)pip3 install tensorflow-gpu==1.13.1   

2)pip3 --version
  pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)   
3)shekh@shekh:~$ python3
  Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
  [GCC 5.4.0 20160609] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>>

https://www.tensorflow.org/install/pip

【讨论】:

    【解决方案2】:

    https://github.com/tensorflow/tensorflow/issues/374

    您是从 tensorflow 目录中打开终端吗?

    “实际上我遇到了这个问题,因为我试图从 tensorflow repo 文件夹中的 python 会话导入 tensorflow,转到其他文件夹并启动 python 并导入 tensorflow 对我有用。”

    【讨论】:

      【解决方案3】:

      我也遇到了这个错误,用这个命令解决了

      python2

      PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages/"
      export PYTHONPATH
      

      python3

      PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.6/dist-packages/"
      export PYTHONPATH
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-06-15
        • 1970-01-01
        • 2019-03-28
        • 2017-12-30
        • 2018-01-06
        • 2018-11-11
        • 2015-04-10
        相关资源
        最近更新 更多