我可以启动jupyter-notebook,但不能启动jupyter-console。在Mac上的dev virtualenv中,它试图从IPython.utils.py3compat导入cast_unicode_py2,但无法导入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)发布于 2020-01-09 02:37:43
简短的回答:
作为临时解决方法,您可以将的第22行更改为:
from ipython_genutils.py3compat import cast_unicode_py2, input
在您的计算机上,要编辑的文件为/Users/harvey/dev/lib/python3.7/site-packages/jupyter_console/ptshell.py.
更长的答案:
Jupyter控制台正在尝试从IPython.utils.py3compat导入cast_unicode_py2和input,但它们已被移动到ipython_genutils.py3compat。这个问题还没有在Jupyter控制台的主分支中修复。
发布于 2020-01-08 01:03:13
在将ipython降级到以前的版本之后,它又可以工作了。我猜cast_unicode_py2已经被弃用了。
发布于 2020-01-17 06:56:57
anaconda现在有些不对劲,因为即使有了全新的虚拟环境,jupyter-console也会产生相同类型的错误,即使源服务器上的ptshell.py文件已经更改为您推荐的格式。我明白了
Traceback (most recent call last):
File "/home/pauljohn/LinuxDownloads/anaconda3/envs/fuzzymatch/bin/jupyter-console", line 7, in <module>
from jupyter_console.app import main
File "/home/pauljohn/LinuxDownloads/anaconda3/envs/fuzzymatch/lib/python3.7/site-packages/jupyter_console/app.py", line 26, in <module>
from jupyter_console.ptshell import ZMQTerminalInteractiveShell
File "/home/pauljohn/LinuxDownloads/anaconda3/envs/fuzzymatch/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此输出是否为您提供了足够的信息来猜测哪里出了问题?
$ conda list --explicit
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
@EXPLICIT
https://repo.anaconda.com/pkgs/main/linux-64/_libgcc_mutex-0.1-main.conda
https://repo.anaconda.com/pkgs/main/linux-64/ca-certificates-2019.11.27-0.conda
https://repo.anaconda.com/pkgs/main/linux-64/ld_impl_linux-64-2.33.1-h53a641e_7.conda
https://repo.anaconda.com/pkgs/main/linux-64/libstdcxx-ng-9.1.0-hdf63c60_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libgcc-ng-9.1.0-hdf63c60_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/expat-2.2.6-he6710b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/gmp-6.1.2-h6c8ec71_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/icu-58.2-h9c2bf20_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/jpeg-9b-h024ee3a_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/libffi-3.2.1-hd88cf55_4.conda
https://repo.anaconda.com/pkgs/main/linux-64/libsodium-1.0.16-h1bed415_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libuuid-1.0.3-h1bed415_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/libxcb-1.13-h1bed415_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/ncurses-6.1-he6710b0_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/openssl-1.1.1d-h7b6447c_3.conda
https://repo.anaconda.com/pkgs/main/linux-64/pcre-8.43-he6710b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/xz-5.2.4-h14c3975_4.conda
https://repo.anaconda.com/pkgs/main/linux-64/zlib-1.2.11-h7b6447c_3.conda
https://repo.anaconda.com/pkgs/main/linux-64/glib-2.63.1-h5a9c865_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libedit-3.1.20181209-hc058e9b_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libpng-1.6.37-hbc83047_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/libxml2-2.9.9-hea5a465_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/pandoc-2.2.3.2-0.conda
https://repo.anaconda.com/pkgs/main/linux-64/readline-7.0-h7b6447c_5.conda
https://repo.anaconda.com/pkgs/main/linux-64/tk-8.6.8-hbc83047_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/zeromq-4.3.1-he6710b0_3.conda
https://repo.anaconda.com/pkgs/main/linux-64/dbus-1.13.12-h746ee38_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/freetype-2.9.1-h8a8886c_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/gstreamer-1.14.0-hb453b48_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/sqlite-3.30.1-h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/fontconfig-2.13.0-h9420a91_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/gst-plugins-base-1.14.0-hbbd80ab_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/python-3.7.6-h0371630_2.conda
https://repo.anaconda.com/pkgs/main/noarch/attrs-19.3.0-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/backcall-0.1.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/certifi-2019.11.28-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/decorator-4.4.1-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/noarch/defusedxml-0.6.0-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/entrypoints-0.3-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/ipython_genutils-0.2.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/markupsafe-1.1.1-py37h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/mistune-0.8.4-py37h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/noarch/more-itertools-8.0.2-py_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pandocfilters-1.4.2-py37_1.conda
https://repo.anaconda.com/pkgs/main/noarch/parso-0.5.2-py_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pickleshare-0.7.5-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/prometheus_client-0.7.1-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/ptyprocess-0.6.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pyzmq-18.1.0-py37he6710b0_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/qt-5.9.7-h5867ecd_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/send2trash-1.5.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/sip-4.19.8-py37hf484d3e_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/six-1.13.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/testpath-0.4.4-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/tornado-6.0.3-py37h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/wcwidth-0.1.7-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/webencodings-0.5.1-py37_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/jedi-0.15.2-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pexpect-4.7.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pyqt-5.9.2-py37h05f1152_2.conda
https://repo.anaconda.com/pkgs/main/linux-64/pyrsistent-0.15.6-py37h7b6447c_0.conda
https://repo.anaconda.com/pkgs/main/noarch/python-dateutil-2.8.1-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/setuptools-44.0.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/terminado-0.8.3-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/traitlets-4.3.3-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/zipp-0.6.0-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/bleach-3.1.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/importlib_metadata-1.3.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/jinja2-2.10.3-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/jupyter_core-4.6.1-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/pygments-2.5.2-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/wheel-0.33.6-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jsonschema-3.2.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jupyter_client-5.3.4-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/pip-19.3.1-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/prompt_toolkit-2.0.9-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/ipython-7.11.1-py37h39e3cac_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/nbformat-4.4.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/ipykernel-5.1.3-py37h39e3cac_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/nbconvert-5.6.1-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/jupyter_console-6.0.0-py37_0.conda
https://repo.anaconda.com/pkgs/main/linux-64/notebook-6.0.2-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/qtconsole-4.6.0-py_1.conda
https://repo.anaconda.com/pkgs/main/linux-64/widgetsnbextension-3.5.1-py37_0.conda
https://repo.anaconda.com/pkgs/main/noarch/ipywidgets-7.5.1-py_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/jupyter-1.0.0-py37_7.conda.utils.py3compat' (/home/pauljohn/LinuxDownloads/anaconda3/envs/fuzzymatch/lib/python3.7/site-packages/IPython/utils/py3compat.py)https://stackoverflow.com/questions/59631663
复制相似问题