Hi!
I'm trying to start a project from the beginning with 1.6rc1 version with python 3.5.0
virtualenv venv
source venv/bin/activate
pip install django-oscar==1.6rc1
django-admin.py startproject mycommerce .
...
Edit settings with https://django-oscar.readthedocs.io/en/latest/internals/getting_started.html
Everything is the same for django 2.0 except for the urls:
from django.contrib import admin
from django.urls import path, include
from oscar.app import application
urlpatterns = [
path('i18n/', include('django.conf.urls.i18n')),
# The Django admin is not officially supported; expect breakage.
# Nonetheless, it's often useful for debugging.
path('admin/', include(admin.site.urls)),
path('', include(application.urls)),
]
But when i execute python manage.py showmigrations i get the error ImportError: No module named 'phonenumbers'.
This is the complete traceback:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/Users/andres/mycommerce/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/oscar/apps/address/models.py", line 1, in <module>
from oscar.apps.address.abstract_models import (
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/oscar/apps/address/abstract_models.py", line 11, in <module>
from phonenumber_field.modelfields import PhoneNumberField
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/phonenumber_field/modelfields.py", line 8, in <module>
from phonenumber_field import formfields
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/phonenumber_field/formfields.py", line 9, in <module>
from phonenumber_field.phonenumber import to_python
File "/Users/andres/mycommerce/venv/lib/python3.5/site-packages/phonenumber_field/phonenumber.py", line 5, in <module>
import phonenumbers
ImportError: No module named 'phonenumbers'
Thanks in advance :).
Andrés.
Try pip install phonenumbers.
If it doesn't work please send your pip freeze.
@Andruten Thanks for reporting the issue.
Whilst pip install phonenumbers will fix the immediate symptom, there is a problem and we're seeing it on one of our projects as well.
This is because we rely on django-phonenumber-field to pull in the phonenumbers dependency, but it does so dynamically, which runs into problems because of how pip caches things.
It works if you do pip install --no-cache-dir, thereby bypassing the cache.
This ideally needs to be fixed in django-phonenumber-field - the less ideal solution would be to make phonenumbers a direct dependency of Oscar.
In the mean time, you need to other clear your pip cache before installing, or just install phonenumbers manually.
I've put a PR in, stefanfoulis/django-phonenumber-field#211. If it doesn't see much movement we will make phonenumbers a direct dependency of Oscar.
Thank you @guijsilva @craigloftus and @solarissmoke :)
See this comment from the maintainer of django-phonenumber-field. I think we just need to add phonenumbers as a dependency of Oscar.