django-seed
django-seed copied to clipboard
psycopg2 is required for ArrayField even if project isn't using postgres
Even though I'm not using Postgres for Django (just yet), the use of ArrayFields requires me to have it installed.
Traceback (most recent call last):
File "/home/forest/Documents/git/megagame-controller/django/manage.py", line 22, in <module>
main()
File "/home/forest/Documents/git/megagame-controller/django/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/home/forest/Documents/git/megagame-controller/django/player/management/commands/seed.py", line 27, in handle
seeder = Seed.seeder(locale="en_CA")
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django_seed/__init__.py", line 43, in seeder
from django_seed import seeder
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django_seed/seeder.py", line 6, in <module>
from django_seed.guessers import NameGuesser, FieldTypeGuesser
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django_seed/guessers.py", line 5, in <module>
from django.contrib.postgres.fields import ArrayField
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/contrib/postgres/fields/__init__.py", line 1, in <module>
from .array import * # NOQA
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/contrib/postgres/fields/array.py", line 3, in <module>
from django.contrib.postgres import lookups
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/contrib/postgres/lookups.py", line 4, in <module>
from .search import SearchVector, SearchVectorExact, SearchVectorField
File "/home/forest/.cache/pypoetry/virtualenvs/backend-6PFENasO-py3.9/lib/python3.9/site-packages/django/contrib/postgres/search.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
pip install psycopg2-binary inside your venv
Possible solution:
https://github.com/Brobin/django-seed/blob/077398a2c2a533b07517b121b34713a2e43bcc63/django_seed/guessers.py#L11
try:
from django.contrib.postgres.fields import ArrayField
except ImportError:
ArrayField = None
https://github.com/Brobin/django-seed/blob/077398a2c2a533b07517b121b34713a2e43bcc63/django_seed/guessers.py#L129
if ArrayField is not None and isinstance(field, ArrayField):
And the same thing for JSONField.
Installing psycopg2-binaryworked for me.