Python 3.7 kernel conflicting with random.py files
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 28/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- jupyter, python
研究方向
在包含空的 random.py 的目錄中啟動 Jupyter Notebook 伺服器以重現此失敗,然後檢查 ipykernel_launcher.py 周圍的啟動路徑,以及 traceback 中顯示的 tempfile.py 匯入。完成的標準是 Python 3 核心能夠啟動並維持可用,且不會匯入本機的 random.py;issue 中未指定目標測試。
由索引模型根據 Issue 內容生成。
描述
Copied over from https://github.com/jupyter/notebook/issues/5470, since this is most likely an ipykernel and not an notebook issue:
When running a jupyter notebook with python 3 kernel from a notebook server started in a directory that contains a file random.py (file must only exist in the same directory, can be empty), the kernel seemingly tries importing from this file in the process:
[I 16:26:31.107 NotebookApp] Kernel started: 2dde5ce2-6742-4523-bbea-1e82edd3f963
Traceback (most recent call last):
File "/home/(...)/.local/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/(...)/.local/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/IPython/__init__.py", line 55, in <module>
from .core.application import Application
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/IPython/core/application.py", line 26, in <module>
from IPython.core.profiledir import ProfileDir, ProfileDirError
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/IPython/core/profiledir.py", line 12, in <module>
from ..paths import get_ipython_package_dir
File "/home/(...)/.local/anaconda3/lib/python3.7/site-packages/IPython/paths.py", line 5, in <module>
import tempfile
File "/home/(...)/.local/anaconda3/lib/python3.7/tempfile.py", line 45, in <module>
from random import Random as _Random
ImportError: cannot import name 'Random' from 'random' (/home/(...)/test/random.py)
where (...) is my user. The server tries to restart the kernel till it hits the limit of 5 tries via the KernelRestarter always resulting in the error above and the kernel dies after that.
[W 16:34:09.714 NotebookApp] KernelRestarter: restart failed
[W 16:34:09.715 NotebookApp] Kernel 2dde5ce2-6742-4523-bbea-1e82edd3f963 died, removing from map.
Updating does not seem to resolve the problem.
Some package-versions that might be interesting (including those pre-update):
Python: 3.7.6
ipykernel: 5.1.4 (tried also 5.1.3)
ipython: 7.13.0 (tried also 7.11.1)
jupyter: 1.0.0
jupyter_client: 6.1.3 (tried also 5.3.4)
jupyter_console: 6.1.0 (tried also 6.0.0)
jupyter_core: 4.6.3 (tried also 4.6.1)
notebook: 6.0.3 (tried also 6.0.2)
- 主要語言
- Python
- 星號
- 734
- 分支
- 411
- 平均合併
- 1 天 2 小時
- 30 天內合併 PR
- 9
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ipython/ipykernel 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 1/5 1 小時以內 新手友好度 72/100
-
難度 4/5 3-5 天 新手友好度 48/100
-
難度 4/5 3-5 天 新手友好度 68/100
查看 ipython/ipykernel 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
anthropics/skills#1811 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·