Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error al ejecutar python manage.py seed api--number=50 #126

Open
kyozApp opened this issue Dec 5, 2024 · 3 comments
Open

Error al ejecutar python manage.py seed api--number=50 #126

kyozApp opened this issue Dec 5, 2024 · 3 comments

Comments

@kyozApp
Copy link

kyozApp commented Dec 5, 2024

(.venv) ❯ pip install django-seed
Collecting django-seed
Using cached django_seed-0.3.1-py3-none-any.whl
Requirement already satisfied: django>=1.11 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from django-seed) (5.1.4)
Requirement already satisfied: Faker>=0.7.7 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from django-seed) (33.1.0)
Requirement already satisfied: toposort>=1.5 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from django-seed) (1.10)
Requirement already satisfied: asgiref<4,>=3.8.1 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from django>=1.11->django-seed) (3.8.1)
Requirement already satisfied: sqlparse>=0.3.1 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from django>=1.11->django-seed) (0.5.2)
Requirement already satisfied: tzdata in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from django>=1.11->django-seed) (2024.2)
Requirement already satisfied: python-dateutil>=2.4 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from Faker>=0.7.7->django-seed) (2.9.0.post0)
Requirement already satisfied: typing-extensions in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from Faker>=0.7.7->django-seed) (4.12.2)
Requirement already satisfied: six>=1.5 in c:\proyectos\personal\python\tutorial\plantilla.venv\lib\site-packages (from python-dateutil>=2.4->Faker>=0.7.7->django-seed) (1.17.0)
Installing collected packages: django-seed
Successfully installed django-seed-0.3.1
(.venv) ❯ python manage.py seed post --number=15
System check identified some issues:

WARNINGS:
?: (staticfiles.W004) The directory '/var/www/static' in the STATICFILES_DIRS setting does not exist.
{'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'skip_checks': False, 'number': 15, 'seeder': None}
Traceback (most recent call last):
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\db\backends\postgresql\psycopg_any.py", line 5, in
from psycopg import ClientCursor, IsolationLevel, adapt, adapters, errors, sql
ModuleNotFoundError: No module named 'psycopg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla\manage.py", line 22, in
main()
~~~~^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla\manage.py", line 18, in main
execute_from_command_line(sys.argv)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management_init_.py", line 442, in execute_from_command_line
utility.execute()
~~~~~~~~~~~~~~~^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management_init_.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management\base.py", line 459, in execute
output = self.handle(*args, **options)
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management\base.py", line 646, in handle
app_output = self.handle_app_config(app_config, **options)
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed\management\commands\seed.py", line 48, in handle_app_config
seeder = Seed.seeder()
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed_init_.py", line 43, in seeder
from django_seed import seeder
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed\seeder.py", line 6, in
from django_seed.guessers import NameGuesser, FieldTypeGuesser
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed\guessers.py", line 5, in
from django.contrib.postgres.fields import ArrayField
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\fields_init_.py", line 1, in
from .array import * # NOQA
^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\fields\array.py", line 4, in
from django.contrib.postgres.forms import SimpleArrayField
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\forms_init_.py", line 3, in
from .ranges import * # NOQA
^^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\forms\ranges.py", line 3, in
from django.db.backends.postgresql.psycopg_any import (
...<3 lines>...
)
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\db\backends\postgresql\psycopg_any.py", line 77, in
from psycopg2 import errors, extensions, sql # NOQA
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'psycopg2'
(.venv) ❯ pip install psycopg2-binary
Collecting psycopg2-binary
Using cached psycopg2_binary-2.9.10-cp313-cp313-win_amd64.whl
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.9.10
(.venv) ❯ python manage.py seed post --number=15
System check identified some issues:

WARNINGS:
?: (staticfiles.W004) The directory '/var/www/static' in the STATICFILES_DIRS setting does not exist.
{'verbosity': 1, 'settings': None, 'pythonpath': None, 'traceback': False, 'no_color': False, 'force_color': False, 'skip_checks': False, 'number': 15, 'seeder': None}
Traceback (most recent call last):
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\db\backends\postgresql\psycopg_any.py", line 5, in
from psycopg import ClientCursor, IsolationLevel, adapt, adapters, errors, sql
ModuleNotFoundError: No module named 'psycopg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla\manage.py", line 22, in
main()
~~~~^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla\manage.py", line 18, in main
execute_from_command_line(sys.argv)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management_init_.py", line 442, in execute_from_command_line
utility.execute()
~~~~~~~~~~~~~~~^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management_init_.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management\base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management\base.py", line 459, in execute
output = self.handle(*args, **options)
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\core\management\base.py", line 646, in handle
app_output = self.handle_app_config(app_config, **options)
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed\management\commands\seed.py", line 48, in handle_app_config
seeder = Seed.seeder()
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed_init_.py", line 43, in seeder
from django_seed import seeder
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed\seeder.py", line 6, in
from django_seed.guessers import NameGuesser, FieldTypeGuesser
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django_seed\guessers.py", line 5, in
from django.contrib.postgres.fields import ArrayField
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\fields_init_.py", line 1, in
from .array import * # NOQA
^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\fields\array.py", line 4, in
from django.contrib.postgres.forms import SimpleArrayField
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\forms_init_.py", line 3, in
from .ranges import * # NOQA
^^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\contrib\postgres\forms\ranges.py", line 3, in
from django.db.backends.postgresql.psycopg_any import (
...<3 lines>...
)
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\django\db\backends\postgresql\psycopg_any.py", line 77, in
from psycopg2 import errors, extensions, sql # NOQA
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Proyectos\Personal\PYTHON\tutorial\plantilla.venv\Lib\site-packages\psycopg2_init_.py", line 51, in
from psycopg2._psycopg import ( # noqa
...<10 lines>...
)
ImportError: DLL load failed while importing _psycopg: No se puede encontrar el módulo especificado.
(.venv) kyoza C:\Proyectos\Personal\PYTHON\tutorial\plantilla 985ms

@sandeepspatil
Copy link

sandeepspatil commented Dec 9, 2024

If you are using latest version of django, you need to install psycopg as latest django uses psycopg3. Use the command

pip install "psycopg[binary]"

Now seed your project DB.

More details:
According to the code, it should work with psycopg2 if psycopg3 is not installed, but it does not. At least installing this solved the issue for me

@kyozApp
Copy link
Author

kyozApp commented Dec 9, 2024

Si me funciono muchas gracias

@Redpythonve
Copy link

If you are using latest version of django, you need to install psycopg as latest django uses psycopg3. Use the command

pip install "psycopg[binary]"

Now seed your project DB.

More details: According to the code, it should work with psycopg2 if psycopg3 is not installed, but it does not. At least installing this solved the issue for me

The best Answer !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants