典型地,一个运行jupyter notebook或jupyter-notebook或ipython notebook在终端局部地启动一个Jupyter笔记本网络服务器(和打开的浏览器中的URL)。使用conda
和conda 环境时,运行允许导入安装在 conda 环境中的 Python 模块的 Jupyter notebook 的最佳方法是什么?
因为它似乎,这 是 不是 很 直 向前 并 不少 用户 都有 类似的 烦恼。
最常见的错误信息似乎是:在康达环境中安装包后,XYZ
my-env一个可以运行import XYZ在开始一个python控制台my-env中,但在运行相同的代码Jupyter笔记本将导致一个ImportError。
这个问题已经问过很多次了,但是没有很好的地方来回答它,大多数问答和Github门票都很混乱,所以让我们在这里开始新的问答。
Jupiter笔记本无法打开笔记本,而是显示“ 500:Internal Server Error”。我所做的就是激活所需的环境并启动Jupyter。请在下面找到我的操作以及终端上的错误消息:
$ conda activate py3_parcels
$ jupyter notebook [I 18:20:39.663 NotebookApp] Loading IPython parallel extension [I 18:20:39.665 NotebookApp] Serving notebooks from local directory: /Users/davidlindo-atichati/run/GOM_MED [I 18:20:39.665 NotebookApp] The Jupyter Notebook is running at: [I 18:20:39.665 NotebookApp] http://localhost:8888/?token=36466fc830862b794856668cd6ded86fe0a664247233764a [I 18:20:39.665 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 18:20:39.677 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=36466fc830862b794856668cd6ded86fe0a664247233764a …Run Code Online (Sandbox Code Playgroud) 我在 PyCharm CE 上安装了 reprexpy 0.3.1,但是当我运行它时,出现以下错误:
(...)
File "/Users/serena/PycharmProjects/pythonProject2/venv/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 14, in <module>
from jinja2 import contextfilter
ImportError: cannot import name 'contextfilter' from 'jinja2' (/Users/serena/PycharmProjects/pythonProject2/venv/lib/python3.7/site-packages/jinja2/__init__.py)
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
按照此处和此处的建议,我尝试在终端中更新 nbconvert:
pip install --upgrade nbconvert
Run Code Online (Sandbox Code Playgroud)
然后我重新启动 PyCharm CE 但我不断收到相同的错误。
当我的浏览器出现“500:内部服务器错误”时,我试图在 Jupyter Notebook 中打开一个 .ipynb 文件。
终端中的错误消息:
[C 23:01:41.750 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/Valeera/AppData/Roaming/jupyter/runtime/nbserver-6072-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=c33d644eeb15c66ec4f8764c7e83023f729f162bbc122f38
[E 23:01:44.821 NotebookApp] Uncaught exception GET /notebooks/1700012779.ipynb (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/1700012779.ipynb', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
File "C:\Users\Valeera\Anaconda3\lib\site-packages\tornado\web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "C:\Users\Valeera\Anaconda3\lib\site-packages\tornado\web.py", line 3174, in wrapper
return method(self, *args, **kwargs)
File "C:\Users\Valeera\Anaconda3\lib\site-packages\notebook\notebook\handlers.py", line 59, in get
get_custom_frontend_exporters=get_custom_frontend_exporters
File "C:\Users\Valeera\Anaconda3\lib\site-packages\notebook\base\handlers.py", line 462, …Run Code Online (Sandbox Code Playgroud)