python - jupyter-console 无法启动,但 jupyter-notebook 很好

标签 python jupyter-notebook ipython

我可以启动 jupyter-notebook 但不能启动 jupyter-console。在 Mac 上的 dev virtualenv 中,它尝试导入 cast_unicode_py2来自 IPython.utils.py3compat , 但是 cast_unicode_py2无法导入:

(dev) C02ZV35VLVDL:profile_default harvey$ jupyter-console
Traceback (most recent call last):
  File "/Users/harvey/dev/bin/jupyter-console", line 5, in <module>
    from jupyter_console.app import main
  File "/Users/harvey/dev/lib/python3.7/site-packages/jupyter_console/app.py", line 26, in <module>
    from jupyter_console.ptshell import ZMQTerminalInteractiveShell
  File "/Users/harvey/dev/lib/python3.7/site-packages/jupyter_console/ptshell.py", line 22, in <module>
    from IPython.utils.py3compat import cast_unicode_py2, input
ImportError: cannot import name 'cast_unicode_py2' from 'IPython.utils.py3compat' (/Users/harvey/dev/lib/python3.7/site-packages/IPython/utils/py3compat.py)

最佳答案

简答:

作为临时解决方法,您可以更改 jupyter_console/jupyter_console/ptshell.py 的第 22 行阅读:
from ipython_genutils.py3compat import cast_unicode_py2, input
在您的计算机上,要编辑的文件是/Users/harvey/dev/lib/python3.7/site-packages/jupyter_console/ptshell.py。

更长的答案:

Jupyter 控制台正在尝试导入cast_unicode_py2input来自 IPython.utils.py3compat但他们已移至 ipython_genutils.py3compat .这在 Jupyter 控制台的 master 分支中尚未修复。

关于python - jupyter-console 无法启动,但 jupyter-notebook 很好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59631663/

相关文章:

python - 无法将 View 从主 Django 项目文件夹导入到 appviews.py 中

tensorflow - 您可以在我的 GCP VM 上使用 Jupyter notebook 在 Google Cloud 中运行 TPU 训练吗?

python - 使用 OpenCV 和 Python 检测图像上不同种类的圆形和椭圆形

python - scipy.sparse.csr.csr_matrix :Matrix extension

python - rsplit() 和 re.split() 的等价物是什么?

python - 在 headless 健身房 jupyter Python 2.7 中获取 "AttributeError: ' ImageData' 对象没有属性 'data'"

python - 一种快速预览 .ipynb 文件的方法

hadoop - 我可以在 Jupyter/IPython 中使用 hadoop 吗?

python - `ipython` 选项卡自动完成对导入的模块不起作用

python-3.x - Pyspark Column.isin() 用于大集合