ModuleNotFoundError: No module named 'sorl'

8.3k Views Asked by At

I'm getting following error during installing django-oscar from https://django-oscar.readthedocs.io/en/2.0.4/internals/getting_started.html

settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',

'oscar',
'oscar.apps.analytics',
'oscar.apps.checkout',
'oscar.apps.address',
'oscar.apps.shipping',
'oscar.apps.catalogue',
'oscar.apps.catalogue.reviews',
'oscar.apps.partner',
'oscar.apps.basket',
'oscar.apps.payment',
'oscar.apps.offer',
'oscar.apps.order',
'oscar.apps.customer',
'oscar.apps.search',
'oscar.apps.voucher',
'oscar.apps.wishlists',
'oscar.apps.dashboard',
'oscar.apps.dashboard.reports',
'oscar.apps.dashboard.users',
'oscar.apps.dashboard.orders',
'oscar.apps.dashboard.catalogue',
'oscar.apps.dashboard.offers',
'oscar.apps.dashboard.partners',
'oscar.apps.dashboard.pages',
'oscar.apps.dashboard.ranges',
'oscar.apps.dashboard.reviews',
'oscar.apps.dashboard.vouchers',
'oscar.apps.dashboard.communications',
'oscar.apps.dashboard.shipping',

# 3rd-party apps that oscar depends on
'widget_tweaks',
'haystack',
'treebeard',
'sorl.thumbnail',
'django_tables2',
]

HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
'URL': 'http://127.0.0.1:8983/solr',
'INCLUDE_SPELLING': True,
},
}

After running py .\manage.py migrate or py .\manage.py makemigrations I got following error

Traceback (most recent call last):
File ".\manage.py", line 21, in
main()
File ".\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 377, in execute
django.setup()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django_init_.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "c:\program files\python37\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'sorl'

I have also found that solr-thumbanil or solr is not install. If I install solr-thumbnail then I get following error

Traceback (most recent call last):
File ".\manage.py", line 21, in
main()
File ".\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\core\management_init_.py", line 377, in execute
django.setup()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django_init_.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\config.py", line 27, in ready
self.password_reset_form = get_class('customer.forms', 'PasswordResetForm')
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 42, in get_class
return get_classes(module_label, [classname], module_prefix)[0]
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 52, in get_classes
return class_loader(module_label, classnames, module_prefix)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 110, in default_class_loader
oscar_module = _import_module(oscar_module_label, classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 144, in _import_module
return import(module_label, fromlist=classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\apps\customer\forms.py", line 14, in
from oscar.apps.customer.utils import get_password_reset_url, normalise_email
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\apps\customer\utils.py", line 8, in
Dispatcher = get_class('communication.utils', 'Dispatcher')
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 42, in get_class
return get_classes(module_label, [classname], module_prefix)[0]
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 52, in get_classes
return class_loader(module_label, classnames, module_prefix)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 110, in default_class_loader
oscar_module = _import_module(oscar_module_label, classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 144, in _import_module
return import(module_label, fromlist=classnames)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\apps\communication\utils.py", line 9, in
CommunicationEventType = get_model('communication', 'CommunicationEventType')
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\oscar\core\loading.py", line 248, in get_model
return apps.get_model(app_label, model_name)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 206, in get_model
app_config = self.get_app_config(app_label)
File "D:\projects\ecommerce\django-oscar-env\lib\site-packages\django\apps\registry.py", line 163, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'communication'.

Technical details

  1. Python version: 3.7.3
  2. Django version: 3.0.10
  3. Oscar version: 2.1
4

There are 4 best solutions below

0
On

There are two issues:

  1. You need to install sorl-thumbnail, which is an optional dependency (this isn't well documented and I'll file an issue to fix that).

  2. You're reading the documentation for version 2.0 of Ocsar, but have installed version 2.1. This is why you are getting the second error No module named 'oscar.apps.dashboard.communication'. Make sure you use the version of the documentation that matches the version you are using.

1
On

In settings.py, in your INSTALLED_APPS list add 'communication',, e.g.:

INSTALLED_APPS = [

'communication',

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
...

If it does not work, check out if the

'`oscar.apps.dashboard.communications'` #plural

module you added in INSTALLED_APPS rather has to be

`oscar.apps.dashboard.communication'` #singular
0
On

You haven't installed a package.

Try this:

pip install sorl-thumbnail
0
On

What solved it for me was:

pip install sorl-thumbnail django-haystack pysolr