jupyter in virtualenviroment sys.path [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-12-11 17:54:17

问题


Jupyter in virtual enviroment doesn't succeed to load (import) libraries

I tried to print sys.path in virtual enviroment JUPYTER and TERMINAL and it looks different.

How it's possible to fix it?

If I print sys.path from terminal and jupyter the output is also different:

from TERMINAL

/Users/myname/virtualenv/ker12/lib/python27.zip /Users/myname/virtualenv/ker12/lib/python2.7 /Users/myname/virtualenv/ker12/lib/python2.7/plat-darwin /Users/myname/virtualenv/ker12/lib/python2.7/plat-mac /Users/myname/virtualenv/ker12/lib/python2.7/plat-mac/lib-scriptpackages /Users/myname/virtualenv/ker12/lib/python2.7/lib-tk /Users/myname/virtualenv/ker12/lib/python2.7/lib-old /Users/myname/virtualenv/ker12/lib/python2.7/lib-dynload /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages /Users/myname/virtualenv/ker12/lib/python2.7/site-packages

from JUPYTER

/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python27.zip /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload /usr/local/lib/python2.7/site-packages /usr/local/lib/python2.7/site-packages/IPython/extensions /Users/myname/.ipython `

It looks, that in sys.path from JUPYTER doesn't include the paths to virtual environment...


回答1:


Try to use the full path (to virtual env) to either the Jupyter notebook or the python bin, e.g.:

python /user/your_name/virtualenv/env1/bin/jupyter-notebook

or

 /user/your_name/virtualenv/env1/bin/python /user/your_name/virtualenv/env1/bin/jupyter-notebook


来源:https://stackoverflow.com/questions/46141764/jupyter-in-virtualenviroment-sys-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!