【发布时间】:2019-05-26 01:00:31
【问题描述】:
我最近在一台新计算机上安装了 Jupyter,在尝试使用和不使用 virtualenv 后,我收到以下与线程模块相关的错误。此错误会阻止笔记本 (1) 打开或 (2) 启动内核。
打开python -m notebook 时出错。笔记本无法成功打开。
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/notebook/nbextensions.py", line 31, in <module>
from .config_manager import BaseJSONConfigManager
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/notebook/config_manager.py", line 15, in <module>
from traitlets.config import LoggingConfigurable
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/traitlets/config/__init__.py", line 6, in <module>
from .application import *
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/traitlets/config/application.py", line 11, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 210, in <module>
_lock = threading.RLock()
AttributeError: module 'threading' has no attribute 'RLock'
Exception ignored in: <module 'threading' from '/Users/me/Downloads/threading.py'>
AttributeError: module 'threading' has no attribute '_shutdown'
切换目录后出错,成功打开notebook,尝试连接内核
[I 09:32:05.828 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/IPython/core/application.py", line 18, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 210, in <module>
_lock = threading.RLock()
AttributeError: module 'threading' has no attribute 'RLock'
Exception ignored in: <module 'threading' from '/Users/me/Downloads/threading.py'>
AttributeError: module 'threading' has no attribute '_shutdown'
由于线程是一个内置模块,我无法更新它。同样,使用正常的site-packages 安装和干净的virtualenv 安装,这个结果是相同的。
【问题讨论】:
标签: python-3.x jupyter-notebook jupyter