Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Python 3.7 kernel conflicting with random.py files

Offen
#512 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
28/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
jupyter, python

Rechercherichtung

Reproduziere den Fehler, indem du einen Jupyter-Notebook-Server in einem Verzeichnis mit einer leeren random.py startest. Untersuche anschließend den Startpfad rund um ipykernel_launcher.py und den in der Traceback-Ausgabe gezeigten Import von tempfile.py. Als erledigt gilt die Aufgabe, wenn der Python 3-Kernel startet und verfügbar bleibt, ohne die lokale random.py zu importieren; im Issue ist kein Zieltest genannt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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)
Vorherrschende Sprache
Python
Sterne
734
Forks
411
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
9

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ipython/ipykernel

Alle Issues in ipython/ipykernel

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.