簡體   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