I am trying to follow the readme to start a django-oscar site, but I cannot get the migrate step to run. Below I have listed the things I tried. The TLDR version is I tried setting django-oscar up in a python3 virtual env, but when I went to migrate and establish the initial sqllite db, I got an error saying could not import django. I am 100% certain my virtual env is active. I tried again using pip3, and again erasing the whole environment and starting over without python3. In all cases I get a "ImportError: Couldn't import Django."
I could use a hand. I have COVID and my troubleshooting skills are a little fuzzy at the moment. Thank you!
mkvirtualenv -p /usr/bin/python3 foobar
pip install django-oscar[sorl-thumbnail]
django-admin startproject foobar
cd foobar/
setvirtualenvproject
# followed the steps at
https://django-oscar.readthedocs.io/en/latest/internals/getting_started.html#install-oscar-and-its-dependenciespython manage.py migrate
# ----------------------------------------
Traceback (most recent call last):
File "manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 13, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
# ----------------------------------------
deactivate
workon foobar
python manage.py migrate
# get same traceback
pip install django
# ----------------------------------------
Requirement already satisfied: django in /home/rob/.local/lib/python3.8/site-packages (3.2.7)
Requirement already satisfied: sqlparse>=0.2.2 in /home/rob/.local/lib/python3.8/site-packages (from django) (0.3.1)
Requirement already satisfied: asgiref<4,>=3.3.2 in /home/rob/.local/lib/python3.8/site-packages (from django) (3.4.1)
Requirement already satisfied: pytz in /home/rob/.local/lib/python3.8/site-packages (from django) (2020.1)
# ----------------------------------------
python
# ----------------------------------------
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
>>>
# ----------------------------------------
pip3 install django
# installed django
python manage.py migrate
# ----------------------------------------
Traceback (most recent call last):
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/core/management/base.py", line 86, in wrapped
saved_locale = translation.get_language()
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/utils/translation/__init__.py", line 254, in get_language
return _trans.get_language()
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
if settings.USE_I18N:
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/rob/development/wands/wands/settings.py", line 1, in <module>
from oscar.defaults import *
ModuleNotFoundError: No module named 'oscar'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/core/management/base.py", line 367, in run_from_argv
connections.close_all()
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/db/utils.py", line 208, in close_all
for alias in self:
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[
self.name] = self.func(instance)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/db/utils.py", line 144, in configure_settings
databases = super().configure_settings(databases)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/home/rob/.virtualenvs/wands/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/rob/development/wands/wands/settings.py", line 1, in <module>
from oscar.defaults import *
ModuleNotFoundError: No module named 'oscar'
# ----------------------------------------
pip install django-oscar
# ----------------------------------------
Requirement already satisfied: django-oscar in /home/rob/.local/lib/python3.8/site-packages (3.1)
Requirement already satisfied: django-widget-tweaks>=1.4.1 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (1.4.9)
Requirement already satisfied: django-treebeard<4.5,>=4.3 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (4.4)
Requirement already satisfied: django-tables2<2.4,>=2.3 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (2.3.4)
Requirement already satisfied: phonenumbers in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (8.12.38)
Requirement already satisfied: pillow>=6.0 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (8.1.0)
Requirement already satisfied: django-haystack>=3.0b1 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (3.1.1)
Requirement already satisfied: Babel<3.0,>=1.0 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (2.9.1)
Requirement already satisfied: purl>=0.7 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (1.6)
Requirement already satisfied: django<3.3,>=2.2 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (3.2.7)
Requirement already satisfied: factory-boy<3.3,>=3.0 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (3.2.1)
Requirement already satisfied: django-extra-views<0.14,>=0.13 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (0.13.0)
Requirement already satisfied: django-phonenumber-field<6.0.0,>=4.0.0 in /home/rob/.local/lib/python3.8/site-packages (from django-oscar) (5.2.0)
Requirement already satisfied: pytz>=2015.7 in /home/rob/.local/lib/python3.8/site-packages (from Babel<3.0,>=1.0->django-oscar) (2020.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from purl>=0.7->django-oscar) (1.14.0)
Requirement already satisfied: asgiref<4,>=3.3.2 in /home/rob/.local/lib/python3.8/site-packages (from django<3.3,>=2.2->django-oscar) (3.4.1)
Requirement already satisfied: sqlparse>=0.2.2 in /home/rob/.local/lib/python3.8/site-packages (from django<3.3,>=2.2->django-oscar) (0.3.1)
Requirement already satisfied: Faker>=0.7.0 in /home/rob/.local/lib/python3.8/site-packages (from factory-boy<3.3,>=3.0->django-oscar) (9.9.0)
Requirement already satisfied: text-unidecode==1.3 in /home/rob/.local/lib/python3.8/site-packages (from Faker>=0.7.0->factory-boy<3.3,>=3.0->django-oscar) (1.3)
Requirement already satisfied: python-dateutil>=2.4 in /usr/lib/python3/dist-packages (from Faker>=0.7.0->factory-boy<3.3,>=3.0->django-oscar) (2.7.3)
# ----------------------------------------
# deleted virtual env, tried all steps again with pip3 instead of pip, same result
# deleted virtual env, tried all steps exactly as written without using a python3 virtual env, same result
# searched django-oscar google group for "Couldn't import Django", didn't find anything