【发布时间】:2016-03-01 19:31:08
【问题描述】:
我有一个开始使用Anaconda 的环境,并且我成功地在其中安装了一个模块。我知道,因为我可以运行python,然后运行import tensorflow。这在通过ipython 时也有效。问题是,我无法从我开始使用ipython notebook 或jupyter 的笔记本中加载模块(即使我从活动环境中执行)。
我怀疑它与ipython 的设置有关,但我不知道如何调试和解决问题。有什么想法吗?
编辑: 以下是我采取的步骤:
-
conda create --name tensorflowproblem python=2.7创造环境 source activate tensorflowproblem-
conda install --name tensorflowproblem jupyter安装jupyter -
pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl安装tensorflow
pip和jupyter的位置:
$ which -a pip
/Users/dror/anaconda/envs/tensorflowproblem/bin/pip
$ which -a jupyter
/Users/dror/anaconda/envs/tensorflowproblem/bin/jupyter
注意目录~/anaconda/envs/tensorflowproblem/lib/python2.7/site-packages/tensorflow存在。
此外,python -c "import tensorflow" 和 ipython -c "import tensorflow" 都不会产生任何类型的错误。
根据要求,也输出
$ conda list -n tensorflowproblem
# packages in environment at /Users/dror/anaconda/envs/tensorflowproblem:
#
appnope 0.1.0 py27_0
backports-abc 0.4 <pip>
backports.ssl-match-hostname 3.4.0.2 <pip>
backports_abc 0.4 py27_0
decorator 4.0.4 py27_0
freetype 2.5.5 0
ipykernel 4.1.1 py27_0
ipython 4.0.0 py27_1
ipython-genutils 0.1.0 <pip>
ipython_genutils 0.1.0 py27_0
ipywidgets 4.1.0 py27_0
jinja2 2.8 py27_0
jsonschema 2.4.0 py27_0
jupyter 1.0.0 py27_0
jupyter-client 4.1.1 <pip>
jupyter-console 4.0.3 <pip>
jupyter-core 4.0.6 <pip>
jupyter_client 4.1.1 py27_0
jupyter_console 4.0.3 py27_0
jupyter_core 4.0.6 py27_0
libpng 1.6.17 0
markupsafe 0.23 py27_0
mistune 0.7.1 py27_0
nbconvert 4.0.0 py27_0
nbformat 4.0.1 py27_0
notebook 4.0.6 py27_0
numpy 1.10.1 <pip>
openssl 1.0.2d 0
path.py 8.1.2 py27_1
pexpect 3.3 py27_0
pickleshare 0.5 py27_0
pip 7.1.2 py27_0
ptyprocess 0.5 py27_0
pygments 2.0.2 py27_0
pyqt 4.11.4 py27_0
python 2.7.10 2
python.app 1.2 py27_4
pyzmq 14.7.0 py27_1
qt 4.8.7 1
qtconsole 4.1.0 py27_0
readline 6.2 2
setuptools 18.5 py27_0
simplegeneric 0.8.1 py27_0
singledispatch 3.4.0.3 py27_0
sip 4.16.9 py27_0
six 1.10.0 py27_0
sqlite 3.8.4.1 1
ssl_match_hostname 3.4.0.2 py27_0
tensorflow 0.5.0 <pip>
terminado 0.5 py27_1
tk 8.5.18 0
tornado 4.3 py27_0
traitlets 4.0.0 py27_0
wheel 0.26.0 py27_1
zeromq 4.1.3 0
zlib 1.2.8 0
另外,根据要求,sys.path 的输出为:
['',
'/Users/user/anaconda/envs/py2/lib/python27.zip',
'/Users/user/anaconda/envs/py2/lib/python2.7',
'/Users/user/anaconda/envs/py2/lib/python2.7/plat-darwin',
'/Users/user/anaconda/envs/py2/lib/python2.7/plat-mac',
'/Users/user/anaconda/envs/py2/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/user/anaconda/envs/py2/lib/python2.7/lib-tk',
'/Users/user/anaconda/envs/py2/lib/python2.7/lib-old',
'/Users/user/anaconda/envs/py2/lib/python2.7/lib-dynload',
'/Users/user/anaconda/envs/py2/lib/python2.7/site-packages',
'/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg',
'/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/aeosa',
'/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/setuptools-17.1.1-py2.7.egg',
'/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/IPython/extensions',
'/Users/user/.ipython']
【问题讨论】:
-
I know it, because I can run python and then import tensorflow- 这并不表明安装到环境中有效。请告诉我们您从激活环境到安装和运行 ipython notebook 的所有步骤。 -
您能否通过
source activate tensorflowproblem激活您的环境,然后运行which -a pipwhich -a jupyter并将输出添加到您的问题中。 -
您是否收到来自
python -c "import tensorflow"和ipython -c "import tensorflow"的任何错误? -
但是,当您运行
ipython notebook并输入import tensorflow时,您会收到错误消息吗?我以前从未见过这样的事情。你能在新单元格中输入ipython notebook并打印出sys.path吗? -
补充一下,我也有同样的问题。我可以在 python 环境中运行它,但不能在 python 环境中运行。我在 Mac el capitan。
标签: python ipython-notebook anaconda jupyter