Netbox considers Python 3.10 to be an invalid Python version (lower than 3.7) #5619

Closed
opened 2025-12-29 19:30:12 +01:00 by adam · 3 comments
Owner

Originally created by @marcus-crane on GitHub (Nov 5, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.9

Python version

3.10

Steps to Reproduce

Running python manage.py runserver using Python 3.10 causes the version check to fail.

This can be confirmed by running a little experiment in the REPL:

> python
Python 3.10.0 (default, Oct 30 2021, 17:17:08) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.python_version_tuple()
('3', '10', '0')
>>> platform.python_version_tuple() > ('3', '7')
False

I don't entirely understand why this is the case but either way, I would propose the following alternative:

> python                                                                                                              11:13pm / 0 / 1
Python 3.10.0 (default, Oct 30 2021, 17:17:08) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version_info
sys.version_info(major=3, minor=10, micro=0, releaselevel='final', serial=0)
>>> sys.version_info > (3, 7)
True

I've got a branch locally that corrects this but as I recall, an issue is required to be approved before any PRs will be accepted so let me know and I'll happily submit a fix.

Expected Behavior

Netbox should run normally using Python 3.10

Observed Behavior

> (venv)  python manage.py runserver 
Traceback (most recent call last):
  File "/Users/marcus/Code/netbox/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 363, in execute
    settings.INSTALLED_APPS
  File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/marcus/.asdf/installs/python/3.10.0/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/marcus/Code/netbox/netbox/netbox/settings.py", line 29, in <module>
    raise RuntimeError(
RuntimeError: NetBox requires Python 3.7 or higher (current: Python 3.10.0)
Originally created by @marcus-crane on GitHub (Nov 5, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.9 ### Python version 3.10 ### Steps to Reproduce Running `python manage.py runserver` using Python 3.10 causes the [version check](https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/settings.py#L28) to fail. This can be confirmed by running a little experiment in the REPL: ```python > python Python 3.10.0 (default, Oct 30 2021, 17:17:08) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.python_version_tuple() ('3', '10', '0') >>> platform.python_version_tuple() > ('3', '7') False ``` I don't entirely understand why this is the case but either way, I would propose the following alternative: ```python > python 11:13pm / 0 / 1 Python 3.10.0 (default, Oct 30 2021, 17:17:08) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.version_info sys.version_info(major=3, minor=10, micro=0, releaselevel='final', serial=0) >>> sys.version_info > (3, 7) True ``` I've got a branch locally that corrects this but as I recall, an issue is required to be approved before any PRs will be accepted so let me know and I'll happily submit a fix. ### Expected Behavior Netbox should run normally using Python 3.10 ### Observed Behavior ```shell > (venv) python manage.py runserver Traceback (most recent call last): File "/Users/marcus/Code/netbox/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 363, in execute settings.INSTALLED_APPS File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name) File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/Users/marcus/Code/netbox/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/Users/marcus/.asdf/installs/python/3.10.0/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/Users/marcus/Code/netbox/netbox/netbox/settings.py", line 29, in <module> raise RuntimeError( RuntimeError: NetBox requires Python 3.7 or higher (current: Python 3.10.0) ```
adam added the type: bugstatus: accepted labels 2025-12-29 19:30:12 +01:00
adam closed this issue 2025-12-29 19:30:12 +01:00
Author
Owner

@sdktr commented on GitHub (Nov 5, 2021):

While I agree on your fix, I don't think that Python 3.10 is supported atm. Whether it's just not tested or unsupported for functional reasons is unknown to me.
So perhaps two enhancements instead of this bug are needed:

  1. Strict(er) python version check (>3.7 <3.10)
  2. Python 3.10 support
@sdktr commented on GitHub (Nov 5, 2021): While I agree on your fix, I don't think that Python 3.10 is supported atm. Whether it's [just not tested](https://github.com/netbox-community/netbox/actions/runs/1418094315/workflow) or unsupported for functional reasons is unknown to me. So perhaps two enhancements instead of this bug are needed: 1) Strict(er) python version check (>3.7 <3.10) 2) Python 3.10 support
Author
Owner

@marcus-crane commented on GitHub (Nov 5, 2021):

While I also think there should be proper validation that it all works with Python 3.10, I do think this check may have just simply been an oversight in how platform.python_version_tuple() works rather than anything intentional as far as 3.10+ is concerned. I never knew this was a thing before I accidentally ran into it just before!

I had a brief poke under the hood and it seems that platform.python_version_tuple is actually just the raw text of sys.version run through a regex which is... interesting.

If I had to guess, the tuple comparison is evaluating the two versions literally (ie; the numeric value of the actual text characters) rather than properly comparing what should really be two floats but I don't really understand on any actual deep level how tuple comparison works though I would be interested to find out :)

Happy for this to be changed from a bug to an enhancement!

@marcus-crane commented on GitHub (Nov 5, 2021): While I also think there should be proper validation that it all works with Python 3.10, I do think this check may have just simply been an oversight in how `platform.python_version_tuple()` works rather than anything intentional as far as 3.10+ is concerned. I never knew this was a thing before I accidentally ran into it just before! I had a [brief poke under the hood](https://github.com/python/cpython/blob/main/Lib/platform.py#L988) and it seems that `platform.python_version_tuple` is actually just the raw text of `sys.version` run through a regex which is... interesting. If I had to guess, the tuple comparison is evaluating the two versions literally (ie; the numeric value of the actual text characters) rather than properly comparing what should really be two floats but I don't really understand on any actual deep level how tuple comparison works though I would be interested to find out :) Happy for this to be changed from a bug to an enhancement!
Author
Owner

@jeremystretch commented on GitHub (Nov 5, 2021):

Nah this is a bug. 3.10 should be evaluated as greater than 3.7. @sdktr is correct in that v3.10 is not officially supported yet, but the check in question is specifically looking for Python versions less than 3.7.

@jeremystretch commented on GitHub (Nov 5, 2021): Nah this is a bug. 3.10 should be evaluated as greater than 3.7. @sdktr is correct in that v3.10 is not officially supported yet, but the check in question is specifically looking for Python versions less than 3.7.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5619