-
Notifications
You must be signed in to change notification settings - Fork 295
Failure to start Kernel due to built in modules being overridden by user code
Python kernels can fail to start if files such as os.py
or random.py
are created in the workspace folder.
Python too has built in modules such as os
and random
, thus when such files are placed in a directory that Python looks for modules, these get loaded instead of the built in modules. As a result the Python run time behaviour is unexpected and in most cases kernels would fail to start successfully.
Note, there are situations when users would want to overwrite such built in modules, however defining such a use case is beyond the scope of this WIKI. When creating such files, please be mindful of how the python runtime loads modules and how it can impact running of kernels.
To get a list of some of the built-in modules or modules in your Python environment use one of the following approachs:
print(dir(__builtins__))
# install [stdlib_list](https://pypi.org/project/stdlib-list/) from [here](https://pypi.org/project/stdlib-list/)
# Here 3.9 is the version of your Python environment.
print(stdlib_list('3.9'))
Please consider renaming the module so that it doesn't conflict with built in modules, e.g. rename random.py
to random_.py
or my_random.py
or other.
For more information about Python modules, please see Modules and Importing Modules
- Contribution
- Source Code Organization
- Coding Standards
- Profiling
- Coding Guidelines
- Component Governance
- Writing tests
- Kernels
- Intellisense
- Debugging
- IPyWidgets
- Extensibility
- Module Dependencies
- Errors thrown
- Jupyter API
- Variable fetching
- Import / Export
- React Webviews: Variable Viewer, Data Viewer, and Plot Viewer
- FAQ
- Kernel Crashes
- Jupyter issues in the Python Interactive Window or Notebook Editor
- Finding the code that is causing high CPU load in production
- How to install extensions from VSIX when using Remote VS Code
- How to connect to a jupyter server for running code in vscode.dev
- Jupyter Kernels and the Jupyter Extension