简体   繁体   English

为什么在安装tensorflow时“没有名为tensorflow的模块”?

[英]Why “No module named tensorflow” when I installed tensorflow?

I use sudo pip install tensorflow-1.7.0rc0-cp27-cp27mu-manylinux1_x86_64.whl in centos7,python version is 2.7.14 我在centos7中使用sudo pip install tensorflow-1.7.0rc0-cp27-cp27mu-manylinux1_x86_64.whl manylinux1_x86_64.whl,python版本是2.7.14

在此处输入图片说明

I get successfully installed tensorflow,but when I run import tensorflow as tf ,I get a error:No module named tensorflow 我成功安装了tensorflow,但是当我将import tensorflow as tf运行时,出现错误:没有名为tensorflow的模块

在此处输入图片说明

what should I do? 我该怎么办? thanks! 谢谢!

As mentioned in the comments you best method for installing pyhton packages is to use a virtual environment. 如评论中所述,安装pyhton软件包的最佳方法是使用虚拟环境。 For a simple way to do this you can install Minicaonda for linux x86 using the following command: 作为一种简单的方法,您可以使用以下命令为linux x86安装Minicaonda

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh

Then it is worth reading the instructions on using conda , to set up a virtual environment called tensorflow . 然后值得阅读有关使用conda来建立名为tensorflow的虚拟环境的tensorflow But the basic command should be: 但是基本命令应该是:

conda create -n tensorflow python=3.6 tensorflow

provided you want to use tensorflow with python3.6. 如果您想在python3.6中使用tensorflow。 Then activate your tensorflow conda environment: 然后激活您的tensorflow conda环境:

source activate tensorflow

and you should be able to import tensorflow without issue. 并且您应该能够顺利导入tensorflow。

(tensorflow) user@machine:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>>

暂无
暂无

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

相关问题 ModuleNotFoundError:没有名为“tensorflow”的模块,即使安装了 tensorflow - ModuleNotFoundError: No module named 'tensorflow', even when tensorflow is installed 安装时没有名为“tensorflow_probability”的模块 - No module named 'tensorflow_probability' when it's installed 当我导入张量流时,它说没有名为“tensorflow”的模块 - When I import tensor flow it says no module named 'tensorflow' "导入 tensorflow 时没有名为“absl”的模块错误" - No module named 'absl' error when I import tensorflow 为什么我不能导入 Tensorflow.contrib 我收到 No module named 'tensorflow.python.saved 的错误 - Why can I not import Tensorflow.contrib I get an error of No module named 'tensorflow.python.saved tensorflow安装正确,但出现错误``ImportError:在导入tensorflow为tf时没有名为'_pywrap_tensorflow_internal'的模块 - tensorflow installed correctly but giving error "ImportError: No module named '_pywrap_tensorflow_internal' on import tensorflow as tf 尽管安装了 tensorflow,当我尝试从 CMD 运行文件时,出现“ModuleNotFoundError: No module named 'tensorflow'”错误 - Inspite of installing tensorflow, `ModuleNotFoundError: No module named 'tensorflow'` error occurs when I try to run files from CMD ModuleNotFoundError:创建 TensorFlow 文档时没有名为“tensorflow_docs”的模块 - ModuleNotFoundError: No module named 'tensorflow_docs' when creating TensorFlow docs ModuleNotFoundError:使用 Tensorflow 时没有名为“pandas”的模块 - ModuleNotFoundError: No module named 'pandas' when working with Tensorflow 我需要解决这个“ModuleNotFoundError: No module named 'tensorflow'” - i need to solve this "ModuleNotFoundError: No module named 'tensorflow'"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM