tensorflow导入错误:使用Python 2.7没有名为tensorflowin Jupyter的模块

问题描述 投票:0回答:1

更新:我试图卸载并重新安装tensorflow。它在命令行中工作,但在Jupyter中,它显示:

ImportError                               Traceback (most recent call last)
<ipython-input-14-40bf8ae976e6> in <module>()
----> 1 import tensorflow

ImportError: No module named tensorflow

我检查了tensorflow的安装位置(它似乎位于正确的位置,但我仍然无法在juypter中成功导入tensorflow):

pip show tensorflow
-bash: syntax error near unexpected token `pip'
 (tensorflow) LPT-010557-PU:~ lzhang22$ pip show tensorflow
Name: tensorflow
Version: 1.10.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /anaconda2/envs/tensorflow/lib/python2.7/site-packages
Requires: astor, tensorboard, setuptools, gast, enum34, protobuf, six, absl-py, backports.weakref, wheel, termcolor, numpy, mock, grpcio

我过去安装了tensorflow,它在Jupyter中运行良好。但有一次我试图安装keras,然后tensorflow开始出现一些问题。我今天尝试在Juypter中导入tensorflow作为tf,但是我遇到了以下导入错误。

===============早期错误在下面,现在更改为上面的错误==============

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-41389fad42b5> in <module>()
----> 1 import tensorflow as tf

/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py in <module>()
 20 
 21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
 23 
 24 try:

/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py in <module>()
 47 import numpy as np
 48 
---> 49 from tensorflow.python import pywrap_tensorflow
 50 
 51 # Protocol buffers

ImportError: cannot import name pywrap_tensorflow

我试图四处搜索,但找不到解决这个问题的答案。

我试过但是它说要求已经满足了:

pip install tensorflow 
Requirement already satisfied: tensorflow in /anaconda2/lib/python2.7/site-packages (1.10.1)

任何见解将不胜感激!

python tensorflow anaconda jupyter-notebook
1个回答
0
投票

安装模块时,请确保您处于正确的环境中。

conda install tensorflow

installing-python-packages-from-jupyter

© www.soinside.com 2019 - 2024. All rights reserved.