Abh*_*war 49 python installation module pip tensorflow
请帮我解决这个错误
我在我的服务器上安装了tensorflow模块,下面是它的信息
15IT60R19@cpusrv-gpu-109:~$ pip show tensorflow
Name: tensorflow
Version: 1.0.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /home/other/15IT60R19/anaconda2/lib/python2.7/site-packages
Requires: mock, numpy, protobuf, wheel, six
Run Code Online (Sandbox Code Playgroud)
但是当我尝试导入tensorflow时,我得到以下错误
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
Run Code Online (Sandbox Code Playgroud)
我的python版本如下
Python 2.7.12 |Anaconda 2.5.0 (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
Run Code Online (Sandbox Code Playgroud)
我尝试过sol1中给出的解决方案
我没有sudo访问服务器我只能使用pip来安装任何模块
Dha*_*rma 27
尝试使用您想要的任何版本再次安装tensorflow,并使用选项--ignore-installed,如:
pip install tensorflow==1.2.0 --ignore-installed
Run Code Online (Sandbox Code Playgroud)
我用这个命令解决了同样的问题.
Cry*_*ptc 22
当我收到此错误时,我遇到了一个更基本的问题.
"验证您的安装"说明请输入:python
但是,我安装了2.7和3.6.因为我使用pip3来安装tensorflow,我需要输入:python3
使用正确的版本,我可以导入"tensorflow"模块.
Alp*_*pa8 18
使用以下命令检查是否已成功安装Tensorflow:
pip3 show tensorflow
Run Code Online (Sandbox Code Playgroud)
如果你得到类似的东西
Name: tensorflow
Version: 1.2.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python3.5/dist-packages
Requires: bleach, markdown, html5lib, backports.weakref, werkzeug, numpy, protobuf, wheel, six
Run Code Online (Sandbox Code Playgroud)
您可以尝试通过以下方式添加tensorflow位置的路径:
export PYTHONPATH=/your/tensorflow/path:$PYTHONPATH.
Run Code Online (Sandbox Code Playgroud)
使用 python2
pip show tensorflow 检查安装
python test.py 运行测试
使用 python3
pip3 show tensorflow 检查安装
python3 test.py 运行测试
测试文件
import tensorflow as tf
import numpy as np
c = np.array([[3.,4], [5.,6], [6.,7]])
step = tf.reduce_mean(c, 1)
with tf.Session() as sess:
print(sess.run(step))
Run Code Online (Sandbox Code Playgroud)
或者,如果你还没有安装tensorflow,试试官方文档
对我来说,如果我这样做了
python3 -m pip install tensorflow
Run Code Online (Sandbox Code Playgroud)
然后我在使用调用tensorflow的第3方库时收到OP报告的错误。
然而,当我替换tensorflow-cpu或tensorflow-gpu(取决于哪一个适合您)时,代码突然能够找到张量流。
您可能需要这样做,因为第一个可能不起作用。
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
| 归档时间: |
|
| 查看次数: |
185790 次 |
| 最近记录: |