inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.29k stars 774 forks source link

Error: No module named 'psycopg2' using installer #4634

Closed Vultik closed 1 year ago

Vultik commented 1 year ago

Deployment Method

Describe the problem*

When running the installer on a fresh ubuntu 20.40 LTS version, there is an issue when using postrgresql db. It seems that it miss a postqresql dependancy that is not installed. Probaby these package: https://docs.inventree.org/en/0.11.0/start/install/#postgresql

Steps to Reproduce

https://docs.inventree.org/en/0.11.0/start/installer/

Relevant log output

File "/opt/inventree/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 237, in fetch_command
    app_name = commands[subcommand]
KeyError: 'dbbackup'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/inventree/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_com
mand_line
    utility.execute()
  File "/opt/inventree/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/inventree/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 244, in fetch_command
    settings.INSTALLED_APPS
  File "/opt/inventree/env/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/opt/inventree/env/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/opt/inventree/env/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 "/opt/inventree/InvenTree/InvenTree/settings.py", line 463, in <module>
    from psycopg2.extensions import (ISOLATION_LEVEL_READ_COMMITTED,
ModuleNotFoundError: No module named 'psycopg2'
Vultik commented 1 year ago

It also crash the inventree server for the same reason : image

Vultik commented 1 year ago

After some discussion with @matmair, it seems that the current installer doesn't handle automatically the installation of the client package for the DB. That means that before running the installer script, you should install manually the python binding listed here : https://docs.inventree.org/en/latest/start/install/#install-python-bindings

The doc should explicity warn the user to setup the db python-binding before running the script. Because for now, the way that the doc is structured, gives the impression that the installer script does all the required job for us, which is not the case.

SchrodingersGat commented 1 year ago

@Vultik can you submit a PR with an update to the docs as you say?

SchrodingersGat commented 1 year ago

@Vultik I'm going to close this out as complete, but keen for you to submit an update to the docs :)