繁体   English   中英

为什么即使在安装 tensorflow 后,Pycharm 中也会出现错误“ModuleNotFoundError: No module named 'tensorflow.python.client'”?

[英]Why do I get the error “ModuleNotFoundError: No module named 'tensorflow.python.client' ” in Pycharm even after installing tensorflow?

我已经通过我的 Mac 上的终端使用 pip 安装了 tensorflow,我正在尝试在 Pycharm 中使用它。 但由于某种原因,我不断收到此错误:

ModuleNotFoundError: No module named 'tensorflow.python.client'

我正在运行此代码:

# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras

# Helper libraries
import numpy as np
import matplotlib.pyplot as plt

print(tf.__version__)

我查看了此页面以进行基本安装( https://www.tensorflow.org/install/pip )并按照终端中的说明运行此代码:

python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

这是对应的output:

2020-07-15 10:57:44.397351: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-07-15 10:57:44.436720: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x12aa14200 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-15 10:57:44.436757: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version 
tf.Tensor(-627.3514, shape=(), dtype=float32)

希望我已经提供了足够的细节来解决问题,我正在尝试使用 tensorflow 运行基本 ML :)

Pycharm 对每个项目都使用虚拟环境。 如果您在设置 -> python 解释器下的 go (见图),您可以检查您正在运行哪一个。 我希望它安装在不同的环境下,您将能够将其切换到正确的环境。

在设置下,选择解释器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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