ethamine ethamine - 4 months ago 17
Python Question

django.core.validators is not a package

I've been struggling with this issue for a couple of days and still can't figure out why this is happening.
I'm trying to at least access a shell via manage.py or perform a migration.
(django 1.9.8, python 3.5.2)

Traceback (most recent call last):
File "gris/gris/manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "/home/user/myenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/user/myenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/myenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 195, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/user/myenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 39, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/user/Python-3.5.2/Lib/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 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ImportError: No module named 'django.core.validators.management'; 'django.core.validators' is not a package


I'm trying to run the script from inside the virtual environment. The weird part is: everything works on MacOS machines and PyCharm is able to run the server.

What have i tried so far:


  1. Made sure i'm using the correct version of python and django.

  2. Took manage.py from a freshly created project and replaced

  3. Grep'ed the filesystem for 'django.core.validators'

  4. Downloaded Python sources, compiled them locally and created new virtual environment

  5. Tried running it without virtual environment

  6. Tried different django(1.9.0, 1.9.6, 1.9.5) and python(3.4, 3.5.2) versions



I ran out of ideas what could cause that. Django.core.validators is not a package, it's a .py file and apparently there's no code trying to access in differently.

Any ideas/suggestions?

My project structure: my_project_structure

Answer

That error would perhaps be raised if django.core.validators was in your INSTALLED_APPS setting.

If it is in your INSTALLED_APPS setting, then it shouldn't be there because it's not an app. Remove it.

Comments