python-3.x - 导入错误 : cannot import name 'Pdb' from 'IPython.core.debugger'

标签 python-3.x jupyter-notebook ipython

看来我根本无法使用 Jupyter notebook。我已经尝试卸载并重新安装,但此错误仍然存​​在。

[I 19:33:14.916 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "/usr/local/lib/python3.7/site-packages/ipykernel/init.py", line 2, in from .connect import * File "/usr/local/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in from IPython.core.profiledir import ProfileDir File "/usr/local/lib/python3.7/site-packages/IPython/init.py", line 54, in from .core.application import Application File "/usr/local/lib/python3.7/site-packages/IPython/core/application.py", line 25, in from IPython.core import release, crashhandler File "/usr/local/lib/python3.7/site-packages/IPython/core/crashhandler.py", line 27, in from IPython.core import ultratb File "/usr/local/lib/python3.7/site-packages/IPython/core/ultratb.py", line 115, in from IPython.core import debugger File "/usr/local/lib/python3.7/site-packages/IPython/core/debugger.py", line 47, in from pdb import Pdb as OldPdb File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pdb.py", line 76, in import code File "/Users/robot/Dropbox/coding/ytautomator/temp/testing_code/code.py", line 17, in fig, ax = plt.subplots(figsize=(15, 8)) File "/usr/local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 1209, in subplots fig = figure(**fig_kw) File "/usr/local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 545, in figure **kwargs) File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 3251, in new_figure_manager fig = fig_cls(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/matplotlib/figure.py", line 367, in init FigureCanvasBase(self) # Set self.canvas. File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1582, in init self._fix_ipython_backend2gui() File "/usr/local/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 1609, in _fix_ipython_backend2gui ip = IPython.get_ipython() File "/usr/local/lib/python3.7/site-packages/IPython/core/getipython.py", line 22, in get_ipython from IPython.core.interactiveshell import InteractiveShell File "/usr/local/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 46, in from IPython.core.debugger import Pdb ImportError: cannot import name 'Pdb' from 'IPython.core.debugger' (/usr/local/lib/python3.7/site-packages/IPython/core/debugger.py)

我在 Mac OS 10.14.6 中使用 Python 3.7.4 和 Anaconda

我的免费 pip 如下:

appnope==0.1.0
attrs==19.3.0
backcall==0.1.0
bleach==3.1.0
cycler==0.10.0
decorator==4.4.0
defusedxml==0.6.0
entrypoints==0.3
importlib-metadata==0.23
ipdb==0.12.2
ipykernel==5.1.2
ipython==7.8.0
ipython-genutils==0.2.0
jedi==0.15.1
Jinja2==2.10.3
json5==0.8.5
jsonschema==3.1.1
jupyter-client==5.3.4
jupyter-core==4.6.0
jupyterlab==1.1.4
jupyterlab-server==1.0.6
kiwisolver==1.1.0
MarkupSafe==1.1.1
matplotlib==3.1.1
mistune==0.8.4
more-itertools==7.2.0
nbconvert==5.6.0
nbformat==4.4.0
notebook==6.0.1
numpy==1.17.2
pandas==0.25.1
pandocfilters==1.4.2
parso==0.5.1
pexpect==4.7.0
pickleshare==0.7.5
prometheus-client==0.7.1
prompt-toolkit==2.0.10
ptyprocess==0.6.0
Pygments==2.4.2
pyparsing==2.4.2
pyrsistent==0.15.4
python-dateutil==2.8.0
pytz==2019.3
pyzmq==18.1.0
Send2Trash==1.5.0
six==1.12.0
terminado==0.8.2
testpath==0.4.2
tornado==6.0.3
traitlets==4.3.3
wcwidth==0.1.7
webencodings==0.5.1
zipp==0.6.0

如果有人能提供帮助,我会很高兴

谢谢

最佳答案

删除文件夹中的文件 code.py。它会引起冲突。

关于python-3.x - 导入错误 : cannot import name 'Pdb' from 'IPython.core.debugger' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58399943/

相关文章:

python - Pandas 按两列分组,一列按行,另一列按列

python - 来自 Jupyter 笔记本的 stdout 重定向正在登陆终端

pandas - 绘制包含 NaN 的 Pandas 数据框

python - 在python笔记本中显示后将图形保存为.pdf

python - 如何在 Excel 中导入 xlwings 函数?

python-3.x - 将数据框“扩展”为矩阵索引

plugins - 在 Sublime Text 2 中运行 IPython Notebook

python - 从 python 控制台使用 grep

python - 尝试遍历多个文本文件并将第 2 行附加到列表

python-3.x - boolean 测试 : Python prints '1' or 'True'