【问题标题】:How to fix the error in Tensorflow in installation in windows?windows下安装Tensorflow报错如何解决?
【发布时间】:2021-03-22 14:42:13
【问题描述】:

我在 Windows Powershell 中安装了 tensorflow,使用

pip install tensorflow

但是当在 anaconda jupyter notebook 中导入 keras(ResNet50) 的依赖项时

from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np

它给了我错误

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-22a529d637ab> in <module>
----> 1 from tensorflow.keras.applications.resnet50 import ResNet50
      2 from tensorflow.keras.preprocessing import image
      3 from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions
      4 import numpy as np

ModuleNotFoundError: No module named 'tensorflow'

【问题讨论】:

  • 在 jupyter 中运行 !pip install tensorflow
  • 可能是因为你安装了多个 Python 并且你将包安装到了错误的一个。

标签: windows tensorflow keras pip anaconda


【解决方案1】:

看起来 TensorFlow 没有安装在 Jupyter 笔记本上 按照以下说明通过创建虚拟环境来安装 Tensorflow。

1. Set Up Anaconda Environments
conda create --name tf_env python=3

2. Activate the new Environment
source activate tf_env

3. Install tensorflow
pip install tensorflow

4. Launch jupyter notebook
jupyter notebook

5. Verify Tensorflow installation
import tensorflow as tf
tf.__version__

【讨论】:

    猜你喜欢
    • 2021-02-27
    • 1970-01-01
    • 2017-11-29
    • 1970-01-01
    • 2020-09-01
    • 2020-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多