shell_plus notebook settings Import error in subdirectory
See original GitHub issueI have an issue where when I run python manage.py shell_plus --notebook
I get an error where it can’t find my Django settings when I navigate and create a notebook in a subdirectory of the project:
WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
[IPKernelApp] WARNING | Error in loading extension: django_extensions.management.notebook_extension
Check your config files in /home/eric/.ipython/profile_default
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/IPython/core/shellapp.py", line 269, in init_extensions
self.shell.extension_manager.load_extension(ext)
File "/usr/local/lib/python2.7/dist-packages/IPython/core/extensions.py", line 86, in load_extension
if self._call_load_ipython_extension(mod):
File "/usr/local/lib/python2.7/dist-packages/IPython/core/extensions.py", line 133, in _call_load_ipython_extension
mod.load_ipython_extension(self.shell)
File "/usr/local/lib/python2.7/dist-packages/django_extensions/management/notebook_extension.py", line 5, in load_ipython_extension
style=no_style())
File "/usr/local/lib/python2.7/dist-packages/django_extensions/management/shells.py", line 102, in import_objects
setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named MY_DJANGO_APP.settings.common
It works when I create a python notebook from the root directory of my project, but not from any subdirectory.
Any suggestions?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:12
- Comments:11 (1 by maintainers)
Top Results From Across the Web
shell_plus notebook settings Import error in subdirectory
I have an issue where when I run python manage.py shell_plus --notebook I get an error where it can't find my Django settings...
Read more >Changing notebook directory leads to an error in loading ...
I'm running an IPython notebook through Django's shell_plus with the following command: sudo ./manage.py shell_plus --notebook.
Read more >zzodosa life: shell_plus notebook settings Import error in ...
shell_plus notebook settings Import error in subdirectory · Issue #865 · django-extensions/django-extensions · Project layout: · settings.py.
Read more >shell_plus — django-extensions 3.2.1 documentation
The Django settings module and database models are auto-loaded into the interactive shell's global namespace also for IPython Notebook. Auto-loading is done by ......
Read more >find subdirectory linux Code Example - Code Grepper
resources/js/bootstrap.js 8:15-31 Module not found: Error: Can't resolve 'axios' · git config --system core.longpaths true · filename too long git ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I managed to work around this problem, in case it’s useful for anyone else. Basically, I added an
ipython_config.py
file to my notebook sub-directory, then manually inserted my base project directory intosys.path
.Project layout:
settings.py
notebooks/ipython_config.py
In the logs, you should observe IPython locating that
ipython_config.py
file in your subdirectory. For example:+1 would love a solution to this problem - i have like 150 notebooks in the root dir of my project, it’s getting out of hand