Python Forum
Have django-extensions installed, can't find shell_plus
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Have django-extensions installed, can't find shell_plus
#1
I am running python 3.7.0 on OpenSuse Leap 15

I have django-extensions installed, but following command fails:
./manage.py shell_plus --notebook
Error:
Unknown command: 'shell_plus'
On searching, it's supposed to be part of django-extensions: https://django-extensions.readthedocs.io..._plus.html

Has anyone encountered this error, and if so, how to resolve?
Reply
#2
I have resolved part of the problem, and the answer is staring me in the face, but my brain is jumbled from frustration, and I'm having trouble finishing right now. At any rate, here's what has been done.

After installing django-extensions in my django virtual environment (which has been activated), here's my pip list:
Output:
... > pip list Package Version ----------------- ------- backcall 0.1.0 decorator 4.3.0 Django 1.8.19 django-extensions 2.0.7 ipython 6.4.0 ipython-genutils 0.2.0 jedi 0.12.1 parso 0.3.1 pexpect 4.6.0 pickleshare 0.7.4 pip 10.0.1 prompt-toolkit 1.0.15 ptyprocess 0.6.0 Pygments 2.2.0 pytz 2018.5 setuptools 39.0.1 simplegeneric 0.8.1 six 1.11.0 traitlets 4.3.2 wcwidth 0.1.7
So I see it's installed in the proper place.
I then discovered (since I'm new to django, didn't immediately realize this step was necessary) that my django application had to be made aware of the package. This is done by adding
    'django-extensions',
to the end of the INSTALLED_APPS list in settings.py

So, after doing that, I try to run:
./manage.py shell_plus --notebook
and get a step further, but still not finding django-extensions:
Error:
Traceback (most recent call last): File "./manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/core/management/__init__.py", line 328, in execute django.setup() File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/apps/config.py", line 86, in create module = import_module(entry) File "/home/Larz60p/.pyenv/versions/3.7.0/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'django-extensions'
So, I have to leave it alone for a bit and come back to it later.
This has to be something simple, but mt tired brain is not in a state where I can recognize what's missing.
Reply
#3
Always use python to run.
/.something it can look outside virtual environment.
Quick demo,i also modify INSTALLED_APPS and add django-extensions:
C:\
λ python -m venv dj_env

C:\
λ cd dj_env

C:\dj_env
λ C:\dj_env\scripts\activate

(dj_env) C:\dj_env
λ pip innstall django django-extensions

(dj_env) C:\dj_env
λ django-admin startproject myproject

(dj_env) C:\dj_env
λ django-admin startapp foo

# Now using python inside virtual enviromnent
(dj_env) C:\dj_env
λ which python
/c/dj_env/Scripts/python

# Test Django Extensions
(dj_env) C:\dj_env\myproject
λ python manage.py shell_plus
# Shell Plus Model Imports
from django.contrib.admin.models import LogEntry
........
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> exit()

(dj_env) C:\dj_env\myproject
λ
Reply
#4
Snippsat,

Thanks for your response.
I am still getting errors:
Output:
Larz60p@linux-nnem:/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog> source ./bin/activate (StartupBlog) Larz60p@linux-nnem:/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog> cd suorganizer/ (StartupBlog) Larz60p@linux-nnem:/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/suorganizer> python manage.py shell_plus Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/core/management/__init__.py", line 328, in execute django.setup() File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/lib/python3.7/site-packages/django/apps/config.py", line 86, in create module = import_module(entry) File "/home/Larz60p/.pyenv/versions/3.7.0/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'django-extensions' (StartupBlog) Larz60p@linux-nnem:/run/media/Larz60p/Data-4TB/python/a-d/d/Django/StartupBlog/suorganizer>
notice that everything is running in the local environment until it tries to run __init__.py which is for some reason being run from my .pyenv environment.
Reply
#5
The module name is django_extensions with _.

Here after I put it at:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',
]
It's working.
Reply
#6
gontajones,
Thanks, that's an elusive one, especially because pip install django-extensions is what's used to load the package, and
pip list shows: django-extensions 2.0.8
Reply
#7
Yeah, I think everybody tried to import it with - at the first time (I did it too).
This must be a recurrent issue at its GitHub!
Reply
#8
you can still import as django-extensions and get the proper package, but the name in setings.py has to have the underscore. Very frustrating!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: View is unable to find attributes of database model pythonpaul32 0 480 Dec-07-2023, 06:38 PM
Last Post: pythonpaul32
Bug Selenium installed but not installed? NoNameoN 9 4,650 Feb-19-2021, 11:31 AM
Last Post: NoNameoN
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,245 Jun-30-2019, 12:21 AM
Last Post: scidam
  Django+uWsgi unable to find "application" callable rosettas 3 11,852 Aug-24-2017, 01:41 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020