ImportError: attempted relative import with no known parent package on startup #3516

Closed
opened 2025-12-29 18:29:36 +01:00 by adam · 1 comment
Owner

Originally created by @fsedano on GitHub (Mar 29, 2020).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.11

Steps to Reproduce

  1. Using 2.7.11 from docker-compose.
    2.Startup fails with the following error

Expected Behavior

Netbox coming up

Observed Behavior

Crash of netbox container on startup:

netbox_1         | ⚙️ Executing '/opt/netbox/startup_scripts/__main__.py'
netbox_1         | /opt/netbox/netbox/netbox/settings.py:187: UserWarning: The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as support for the old name will be removed in a future release.
netbox_1         |   "The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as "
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/check.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/compilemessages.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/createcachetable.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/dbshell.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/diffsettings.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/dumpdata.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/flush.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/inspectdb.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/loaddata.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/makemessages.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sendtestemail.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/shell.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/showmigrations.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sqlflush.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sqlmigrate.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sqlsequencereset.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/squashmigrations.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/startapp.py
netbox_1         | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/startproject.py
netbox_1         | Traceback (most recent call last):
netbox_1         |   File "./manage.py", line 10, in <module>
netbox_1         |     execute_from_command_line(sys.argv)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
netbox_1         |     utility.execute()
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
netbox_1         |     self.fetch_command(subcommand).run_from_argv(self.argv)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
netbox_1         |     self.execute(*args, **cmd_options)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
netbox_1         |     output = self.handle(*args, **options)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/shell.py", line 92, in handle
netbox_1         |     exec(sys.stdin.read())
netbox_1         |   File "<string>", line 18, in <module>
netbox_1         |   File "/usr/local/lib/python3.7/runpy.py", line 263, in run_path
netbox_1         |     pkg_name=pkg_name, script_name=fname)
netbox_1         |   File "/usr/local/lib/python3.7/runpy.py", line 96, in _run_module_code
netbox_1         |     mod_name, mod_spec, pkg_name, script_name)
netbox_1         |   File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
netbox_1         |     exec(code, run_globals)
netbox_1         |   File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/startproject.py", line 3, in <module>
netbox_1         |     from ..utils import get_random_secret_key
netbox_1         | ImportError: attempted relative import with no known parent package
netbox-mar28_netbox_1 exited with code 1
Originally created by @fsedano on GitHub (Mar 29, 2020). ### Environment * Python version: 3.6.9 * NetBox version: 2.7.11 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Using 2.7.11 from docker-compose. 2.Startup fails with the following error <!-- What did you expect to happen? --> ### Expected Behavior Netbox coming up <!-- What happened instead? --> ### Observed Behavior Crash of netbox container on startup: ``` netbox_1 | ⚙️ Executing '/opt/netbox/startup_scripts/__main__.py' netbox_1 | /opt/netbox/netbox/netbox/settings.py:187: UserWarning: The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as support for the old name will be removed in a future release. netbox_1 | "The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as " netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/check.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/compilemessages.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/createcachetable.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/dbshell.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/diffsettings.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/dumpdata.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/flush.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/inspectdb.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/loaddata.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/makemessages.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sendtestemail.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/shell.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/showmigrations.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sqlflush.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sqlmigrate.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/sqlsequencereset.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/squashmigrations.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/startapp.py netbox_1 | Running /usr/local/lib/python3.7/site-packages/django/core/management/commands/startproject.py netbox_1 | Traceback (most recent call last): netbox_1 | File "./manage.py", line 10, in <module> netbox_1 | execute_from_command_line(sys.argv) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line netbox_1 | utility.execute() netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute netbox_1 | self.fetch_command(subcommand).run_from_argv(self.argv) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv netbox_1 | self.execute(*args, **cmd_options) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute netbox_1 | output = self.handle(*args, **options) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/shell.py", line 92, in handle netbox_1 | exec(sys.stdin.read()) netbox_1 | File "<string>", line 18, in <module> netbox_1 | File "/usr/local/lib/python3.7/runpy.py", line 263, in run_path netbox_1 | pkg_name=pkg_name, script_name=fname) netbox_1 | File "/usr/local/lib/python3.7/runpy.py", line 96, in _run_module_code netbox_1 | mod_name, mod_spec, pkg_name, script_name) netbox_1 | File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code netbox_1 | exec(code, run_globals) netbox_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/startproject.py", line 3, in <module> netbox_1 | from ..utils import get_random_secret_key netbox_1 | ImportError: attempted relative import with no known parent package netbox-mar28_netbox_1 exited with code 1 ```
adam closed this issue 2025-12-29 18:29:36 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 30, 2020):

We don't provide support for Docker packages. Please raise a bug against the package itself.

@jeremystretch commented on GitHub (Mar 30, 2020): We don't provide support for Docker packages. Please raise a bug against the package itself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3516