Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Python 3.7 kernel conflicting with random.py files

Abierto
#512 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
28/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
jupyter, python

Línea de trabajo

Reproduce el fallo iniciando un servidor de Jupyter Notebook en un directorio que contenga un random.py vacío; después, inspecciona la ruta de inicio alrededor de ipykernel_launcher.py y la importación de tempfile.py que se muestra en el traceback. Se considera terminado cuando el kernel de Python 3 se inicia y permanece disponible sin importar el random.py local; en el issue no se nombra ninguna prueba objetivo.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)
Lenguaje dominante
Python
Estrellas
734
Forks
411
Merge medio
1 d 2 h
PR fusionados (30 d)
9

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ipython/ipykernel

Todos los issues de ipython/ipykernel

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.