【问题标题】:No module named 'tensorflow' in Anaconda3 on a MacBookMacBook 上的 Anaconda3 中没有名为“tensorflow”的模块
【发布时间】:2019-07-17 19:44:15
【问题描述】:

当我尝试使用我的 Anaconda3 import tensorflow 时,JupyterLab 给出了以下错误消息:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf

ModuleNotFoundError: No module named 'tensorflow'

我确信我已经在我的 MacBook 上的 python 和 python3 中安装了 TensorFlow:

⋊> ~ pip3 show tensorflow                                          11:54:49
Name: tensorflow
Version: 1.13.0rc2
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/local/lib/python3.7/site-packages
Requires: termcolor, tensorboard, keras-applications, keras-preprocessing, grpcio, numpy, six, absl-py, protobuf, wheel, astor, tensorflow-estimator, gast
Required-by: 

import tensorflow在终端中使用python3也可以,但是在我将Anaconda路径添加到fish shell之后,它给出了这个错误消息:

⋊> ~ python3                                                        12:09:48
Python 3.7.1 (default, Dec 14 2018, 13:28:58) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>> 

另外,我刚刚试了conda install tensorflow,结果爆:

⋊> ~ conda install tensorflow                                       
12:24:09
    Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - anaconda==2018.12=py37_0 -> cython==0.29.2=py37h0a44026_0
  - anaconda==2018.12=py37_0 -> mkl-service==1.1.2=py37hfbe908c_5
  - anaconda==2018.12=py37_0 -> numexpr==2.6.8=py37h7413580_0
  - anaconda==2018.12=py37_0 -> scikit-learn==0.20.1=py37h27c97d8_0
  - tensorflow
Use "conda info <package>" to see the dependencies for each package.

【问题讨论】:

  • Anaconda 不附带 tensorflow... 只需安装它
  • 如果您可以使用 conda 命令 intall 使用 conda install tensorflow。此命令将在您当前的活动环境中安装 tensorflow。
  • /usr/local/lib/python3.7/site-packages:这看起来不像 anaconda 路径。试试pip show tensorflow。它显示了什么
  • pip show tensorflow 以前显示什么,现在什么都不显示
  • 试试which pip。路径是什么

标签: python python-3.x tensorflow path anaconda


【解决方案1】:

基于this,当您使用带有Python3 的Mac 时,您可以使用pip3 install --upgrade tensorflow 安装它。

【讨论】:

  • 感谢您的回复。但我应该做pip 还是pip3
  • 所有的要求都已经满足了。什么都没做
  • 如果您使用的是 Conda,您应该在文档中使用 venv 关注 Conda 安装
猜你喜欢
  • 2018-11-23
  • 2018-10-14
  • 2021-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-08
  • 2018-01-10
相关资源
最近更新 更多