Python ModuleNotFoundError没有名为'的模块;tensorflow';从命令行窗口运行脚本时

Python ModuleNotFoundError没有名为'的模块;tensorflow';从命令行窗口运行脚本时,python,tensorflow,Python,Tensorflow,我正在尝试从命令行运行脚本来对图像进行分类。 当我从Pycharm终端运行脚本时,它工作正常,但当我尝试从命令行运行时,出现错误: File "process.py", line 3, in <module> import tensorflow as tf ModuleNotFoundError: No module named 'tensorflow' 如何修复此错误?在python安装中,tenserflow模块的路径可能不在搜索模块的路径中。您必须

我正在尝试从命令行运行脚本来对图像进行分类。 当我从Pycharm终端运行脚本时,它工作正常,但当我尝试从命令行运行时,出现错误:

File "process.py", line 3, in <module>
   import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow' 

如何修复此错误?

在python安装中,tenserflow模块的路径可能不在搜索模块的路径中。您必须通过以下方式将tenserflow模块的路径显式添加到process.py文件中:

import sys
sys.path.insert(1, "<path to tenserflow module>")
import tenserflow as tf
导入系统 系统路径插入(1,“”) 导入tenserflow作为tf 代码可能在pycharm中工作,因为tenserflow模块的路径可能在pycharm的模块搜索目录中

pip install tensorflow

OR

pip3 install tensorflow

in terminal/cmd

如果您使用的是virtualenv/venv/anaconda,您需要激活它

您使用的是anaconda吗?pip3显示tensorflow此命令的输出是什么?如果不使用anaconda,请尝试此pip安装tensorflow==1.2.0——忽略安装我使用的是PyCharm IDE,当从PyCharm终端运行Python脚本时,它会工作,当尝试从windows命令行运行脚本时,它会显示此错误。检查此项我尝试将代码添加到tensorflow模块的路径,并且存在相同的erorr。
pip install tensorflow

OR

pip3 install tensorflow

in terminal/cmd