我正在使用适用于Python的AWS AMI。问题是我无法通过jupyter notebook加载模块,但可以在终端的Ipython中加载模块。所以问题出在Jupyter笔记本上。 ipython的sys.path和sys.executable是 ['', '/ home / ubuntu / anaconda3 / envs / pytorch_p36 / bin', '/ home / ubuntu / src / cntk / bindings / python', '/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python36.zip', '/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6', '/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/lib-dynload', '/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages', '/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/IPython/extensions', '/ tmp / tmp9g6o18fr']
'/ home / ubuntu / anaconda3 / envs / pytorch_p36 / bin / python'
,并且在jupyter Notebook中的相同值是 ['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/ usr / lib / python3 / dist-packages', '/usr/local/lib/python3.5/dist-packages/IPython/extensions', '/home/ubuntu/.ipython']
和 / usr / bin / python3' 这完全是问题的根本原因。 我尝试在jupyter笔记本中清除并设置sys.path,但它对某些模块给出了错误。如何更改jupyter笔记本的配置。 如果我尝试在环境中安装jupyter笔记本,也会收到错误消息。我已经浏览了以下链接https://www.lucypark.kr/blog/2013/02/10/when-python-imports-and-ipython-does-not/ 和https://github.com/jupyter/notebook/issues/1524。