I have just started using Jupyter notebooks in VSCode and have come across a strange issue. I made a folder for keeping my lab programs and there is a file named random.py in the folder. When I try to execute a code cell of my Jupyter notebook which is present in the same folder then I get an error 'Kernel died with exit code 1'. If I delete the contents of the random.py file and just make it an empty file then also the issue persists. The issue is resolved if I remove the file named random.py or change it's name to something else like random1.py.
I have read about 'Kernel died with exit code 1' error here and here.
My Environment data
- VS Code version: 1.59.0
- Jupyter Extension version: v2021.8.1236758218
- Python Extension version: v2021.8.1105858891
- OS: Windows 10
- Python version: 3.8.5 64-bit
- Type of virtual environment used: Global (I am not completely sure but this is the environment based on the vscode docs that I've read on python environments) Here is the image to make this clear - image showing that I don't have any 'base: conda' or something like that
- Jupyter server running: Local
I do not have Anaconda installed on my system. I tried the fixes told in the above links but none of them worked. If I put the Jupyter notebook in any other folder and run the cell code then it runs perfectly fine. I want to know that is it possible for a Jupyter notebook to not run when there's a file named 'random.py' present in the same folder? I have not seen this issue reported anywhere else so I am putting it here so that I can get some help on it.
Here are the screenshots for the proof -
Here is the complete error message -
Kernel died with exit code 1. Traceback (most recent call last): File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main return run_code(code, main_globals, None, File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in run_code exec(code, run_globals) File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel_init.py", line 2, in from .connect import * File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel\connect.py", line 12, in import jupyter_client File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\jupyter_client_init.py", line 4, in from .connect import * File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\jupyter_client\connect.py", line 16, in import tempfile File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\tempfile.py", line 45, in from random import Random as _Random ImportError: cannot import name 'Random' from 'random' (d:\LABS\AI Lab\lab3\random.py)