Skip to content

Module not found error after updating from 2.8.0 to a newer version #1459

@Kleinrotti

Description

@Kleinrotti

Current Behavior

I wanted to update from the 2.8.0 release to 3.2.1. But when building the plugin image with:
docker compose build --no-cache

This error appears:

=> ERROR [netbox 6/6] RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bi 0.9s
[netbox 6/6] RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input:
0.744 Traceback (most recent call last):
0.744 File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/init.py", line 255, in fetch_command
0.745 app_name = commands[subcommand]
0.745 ~~~~~~~~^^^^^^^^^^^^
0.745 KeyError: 'collectstatic'
0.745
0.745 During handling of the above exception, another exception occurred:
0.745
0.745 Traceback (most recent call last):
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/postgresql/psycopg_any.py", line 5, in
0.745 from psycopg import ClientCursor, IsolationLevel, adapt, adapters, errors, sql
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/init.py", line 9, in
0.745 from . import pq # noqa: F401 import early to stabilize side effects
0.745 ^^^^^^^^^^^^^^^^
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/pq/init.py", line 18, in
0.745 from . import abc
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/pq/abc.py", line 13, in
0.745 from .._compat import Self, TypeAlias
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/_compat.py", line 48, in
0.745 from typing_extensions import TypeVar
0.745 ImportError: cannot import name 'TypeVar' from 'typing_extensions' (/opt/netbox/venv/lib/python3.12/site-packages/typing_extensions.py). Did you mean: 'TypeGuard'?
0.745
0.745 During handling of the above exception, another exception occurred:
0.745
0.745 Traceback (most recent call last):
0.745 File "/opt/netbox/netbox/manage.py", line 10, in
0.745 execute_from_command_line(sys.argv)
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
0.745 utility.execute()
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/init.py", line 436, in execute
0.745 self.fetch_command(subcommand).run_from_argv(self.argv)
0.745 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/init.py", line 262, in fetch_command
0.745 settings.INSTALLED_APPS
0.745 File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/init.py", line 81, in getattr
0.746 self._setup(name)
0.746 File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/init.py", line 68, in _setup
0.746 self._wrapped = Settings(settings_module)
0.746 ^^^^^^^^^^^^^^^^^^^^^^^^^
0.746 File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/init.py", line 166, in init
0.746 mod = importlib.import_module(self.SETTINGS_MODULE)
0.746 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.746 File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module
0.746 return _bootstrap._gcd_import(name[level:], package, level)
0.746 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.746 File "", line 1387, in _gcd_import
0.746 File "", line 1360, in _find_and_load
0.746 File "", line 1331, in _find_and_load_unlocked
0.746 File "", line 935, in _load_unlocked
0.746 File "", line 995, in exec_module
0.746 File "", line 488, in _call_with_frames_removed
0.746 File "/opt/netbox/netbox/netbox/settings.py", line 14, in
0.746 from netbox.config import PARAMS as CONFIG_PARAMS
0.746 File "/opt/netbox/netbox/netbox/config/init.py", line 9, in
0.746 from .parameters import PARAMS
0.746 File "/opt/netbox/netbox/netbox/config/parameters.py", line 2, in
0.746 from django.contrib.postgres.forms import SimpleArrayField
0.746 File "/opt/netbox/venv/lib/python3.12/site-packages/django/contrib/postgres/forms/init.py", line 3, in
0.746 from .ranges import * # NOQA
0.746 ^^^^^^^^^^^^^^^^^^^^^
0.746 File "/opt/netbox/venv/lib/python3.12/site-packages/django/contrib/postgres/forms/ranges.py", line 3, in
0.746 from django.db.backends.postgresql.psycopg_any import (
0.746 File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/postgresql/psycopg_any.py", line 77, in
0.746 from psycopg2 import errors, extensions, sql # NOQA
0.746 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.746 ModuleNotFoundError: No module named 'psycopg2'

failed to solve: process "/bin/sh -c DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input" did not complete successfully: exit code: 1

This is my Dockerfile-Plugins:

`FROM netboxcommunity/netbox:${VERSION-v4.2-3.2.1}

COPY ./plugin_requirements.txt /opt/netbox/
RUN /usr/local/bin/uv pip install -r /opt/netbox/plugin_requirements.txt

COPY configuration/configuration.py /etc/netbox/config/configuration.py
COPY configuration/plugins.py /etc/netbox/config/plugins.py
RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy"
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input`

Expected Behavior

The build should be successful.

Docker Compose Version

v2.32.4

Docker Version

Client: Docker Engine - Community
 Version:           27.5.1
 API version:       1.47
 Go version:        go1.22.11
 Git commit:        9f9e405
 Built:             Wed Jan 22 13:41:05 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.5.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.11
  Git commit:       4c9b3b0
  Built:            Wed Jan 22 13:41:05 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.25
  GitCommit:        bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc:
  Version:          1.2.4
  GitCommit:        v1.2.4-0-g6c52b3f
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

The git Revision

2efacf3

The git Status

HEAD detached at 3.2.1
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	Dockerfile-Plugins
	custom_code/
	plugin_requirements.txt

nothing added to commit but untracked files present (use "git add" to track)

Startup Command

docker compose build --no-cache

NetBox Logs

=> ERROR [netbox 6/6] RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy"     /opt/netbox/venv/bi  0.9s 
 [netbox 6/6] RUN DEBUG="true" SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy"     /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input:                                                                                     
0.744 Traceback (most recent call last):                                                                                              
0.744   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 255, in fetch_command           
0.745     app_name = commands[subcommand]                                                                                             
0.745                ~~~~~~~~^^^^^^^^^^^^
0.745 KeyError: 'collectstatic'
0.745 
0.745 During handling of the above exception, another exception occurred:
0.745 
0.745 Traceback (most recent call last):
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/postgresql/psycopg_any.py", line 5, in <module>
0.745     from psycopg import ClientCursor, IsolationLevel, adapt, adapters, errors, sql
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/__init__.py", line 9, in <module>
0.745     from . import pq  # noqa: F401 import early to stabilize side effects
0.745     ^^^^^^^^^^^^^^^^
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/pq/__init__.py", line 18, in <module>
0.745     from . import abc
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/pq/abc.py", line 13, in <module>
0.745     from .._compat import Self, TypeAlias
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/psycopg/_compat.py", line 48, in <module>
0.745     from typing_extensions import TypeVar
0.745 ImportError: cannot import name 'TypeVar' from 'typing_extensions' (/opt/netbox/venv/lib/python3.12/site-packages/typing_extensions.py). Did you mean: 'TypeGuard'?
0.745 
0.745 During handling of the above exception, another exception occurred:
0.745 
0.745 Traceback (most recent call last):
0.745   File "/opt/netbox/netbox/manage.py", line 10, in <module>
0.745     execute_from_command_line(sys.argv)
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
0.745     utility.execute()
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
0.745     self.fetch_command(subcommand).run_from_argv(self.argv)
0.745     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 262, in fetch_command
0.745     settings.INSTALLED_APPS
0.745   File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/__init__.py", line 81, in __getattr__
0.746     self._setup(name)
0.746   File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/__init__.py", line 68, in _setup
0.746     self._wrapped = Settings(settings_module)
0.746                     ^^^^^^^^^^^^^^^^^^^^^^^^^
0.746   File "/opt/netbox/venv/lib/python3.12/site-packages/django/conf/__init__.py", line 166, in __init__
0.746     mod = importlib.import_module(self.SETTINGS_MODULE)
0.746           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.746   File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
0.746     return _bootstrap._gcd_import(name[level:], package, level)
0.746            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.746   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
0.746   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
0.746   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
0.746   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
0.746   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
0.746   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
0.746   File "/opt/netbox/netbox/netbox/settings.py", line 14, in <module>
0.746     from netbox.config import PARAMS as CONFIG_PARAMS
0.746   File "/opt/netbox/netbox/netbox/config/__init__.py", line 9, in <module>
0.746     from .parameters import PARAMS
0.746   File "/opt/netbox/netbox/netbox/config/parameters.py", line 2, in <module>
0.746     from django.contrib.postgres.forms import SimpleArrayField
0.746   File "/opt/netbox/venv/lib/python3.12/site-packages/django/contrib/postgres/forms/__init__.py", line 3, in <module>
0.746     from .ranges import *  # NOQA
0.746     ^^^^^^^^^^^^^^^^^^^^^
0.746   File "/opt/netbox/venv/lib/python3.12/site-packages/django/contrib/postgres/forms/ranges.py", line 3, in <module>
0.746     from django.db.backends.postgresql.psycopg_any import (
0.746   File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/backends/postgresql/psycopg_any.py", line 77, in <module>
0.746     from psycopg2 import errors, extensions, sql  # NOQA
0.746     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.746 ModuleNotFoundError: No module named 'psycopg2'

failed to solve: process "/bin/sh -c DEBUG=\"true\" SECRET_KEY=\"dummydummydummydummydummydummydummydummydummydummy\"     /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input" did not complete successfully: exit code: 1

Content of docker-compose.override.yml

services:
  netbox:
    image: netbox:latest-plugins
    pull_policy: never
    ports:
      - 8004:8080
    build:
      context: .
      dockerfile: Dockerfile-Plugins
    restart: unless-stopped
    #env_file: env/netbox.override.env
    healthcheck:
      start_period: 120s
    volumes:
      - ./custom_code:/opt/netbox/netbox/custom_code
  netbox-worker:
    image: netbox:latest-plugins
    pull_policy: never
    restart: unless-stopped
    #env_file: env/netbox.override.env
    volumes:
      - ./custom_code:/opt/netbox/netbox/custom_code
  netbox-housekeeping:
    image: netbox:latest-plugins
    pull_policy: never
    restart: unless-stopped
    #env_file: env/netbox.override.env
    volumes:
      - ./custom_code:/opt/netbox/netbox/custom_code
  postgres:
    restart: unless-stopped
    #env_file: env/postgres.override.env
  redis:
    restart: unless-stopped
    #env_file: env/redis.override.env
  redis-cache:
    restart: unless-stopped
    #env_file: env/redis-cache.override.env

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions