ImportError when upgrading to 2.0.5 using upgrade.sh #1017

Closed
opened 2025-12-29 16:27:55 +01:00 by adam · 7 comments
Owner

Originally created by @lucianopm on GitHub (Jun 8, 2017).

Updating via GIT from 2.0.4 to 2.0.5:

cd /opt/netbox
git checkout master
git pull origin master
./upgrade.sh

Error:

Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):
  File "netbox/manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named 'django'
Collecting static files (python3 netbox/manage.py collectstatic --no-input)...
Traceback (most recent call last):
  File "netbox/manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named 'django'
Originally created by @lucianopm on GitHub (Jun 8, 2017). Updating via GIT from 2.0.4 to 2.0.5: ``` cd /opt/netbox git checkout master git pull origin master ./upgrade.sh ``` Error: ``` Applying database migrations (python3 netbox/manage.py migrate)... Traceback (most recent call last): File "netbox/manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named 'django' Collecting static files (python3 netbox/manage.py collectstatic --no-input)... Traceback (most recent call last): File "netbox/manage.py", line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named 'django' ```
adam added the type: bug label 2025-12-29 16:27:55 +01:00
adam closed this issue 2025-12-29 16:27:55 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 8, 2017):

What version of Python are you running NetBox on?

@jeremystretch commented on GitHub (Jun 8, 2017): What version of Python are you running NetBox on?
Author
Owner

@lucianopm commented on GitHub (Jun 8, 2017):

root@netbox:/opt/netbox# python3 --version
Python 3.5.2

@lucianopm commented on GitHub (Jun 8, 2017): root@netbox:/opt/netbox# python3 --version Python 3.5.2
Author
Owner

@lampwins commented on GitHub (Jun 8, 2017):

Also just hit this. So apparently (at least on my dev 16.04 box), ubuntu ships with python and python3 but only pip. So the upgrade script chooses python3 but is forced to choose pip.

So seems like the upgrade script needs to be changed to use python3 & pip3 OR python & pip, not one of each.

andersonjd@netbox-dev:/opt/netbox$ sudo ./upgrade.sh 
Running NetBox upgrade as root, press any key to continue or ^C to cancel
Cleaning up stale Python bytecode (find . -name "*.pyc" -delete)...
Updating required Python packages (pip install -r requirements.txt --upgrade)...

...

Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):

@lampwins commented on GitHub (Jun 8, 2017): Also just hit this. So apparently (at least on my dev 16.04 box), ubuntu ships with python and python3 but only pip. So the upgrade script chooses python3 but is forced to choose pip. So seems like the upgrade script needs to be changed to use python3 & pip3 OR python & pip, not one of each. ``` andersonjd@netbox-dev:/opt/netbox$ sudo ./upgrade.sh Running NetBox upgrade as root, press any key to continue or ^C to cancel Cleaning up stale Python bytecode (find . -name "*.pyc" -delete)... Updating required Python packages (pip install -r requirements.txt --upgrade)... ... Applying database migrations (python3 netbox/manage.py migrate)... Traceback (most recent call last): ```
Author
Owner

@jeremystretch commented on GitHub (Jun 8, 2017):

Awesome. Yeah, the Python 2/3 stuff is a mess. The upgrade script defaults to py3 as of 834c396a22 but it has no way to know which it should use if both versions are installed.

@jeremystretch commented on GitHub (Jun 8, 2017): Awesome. Yeah, the Python 2/3 stuff is a mess. The upgrade script defaults to py3 as of 834c396a2204ff639c47a6765cb870294b387760 but it has no way to know which it should use if both versions are installed.
Author
Owner

@jeremystretch commented on GitHub (Jun 8, 2017):

Workaround

Here's a temporary workaround for people running into this bug. Instead of running upgrade.sh, run one of the following sets of commands from the NetBox installation path.

Python 2

sudo pip install -r requirements.txt --upgrade
python netbox/manage.py migrate
python netbox/manage.py collectstatic --no-input

Python 3

sudo pip3 install -r requirements.txt --upgrade
python3 netbox/manage.py migrate
python3 netbox/manage.py collectstatic --no-input
@jeremystretch commented on GitHub (Jun 8, 2017): ## Workaround Here's a temporary workaround for people running into this bug. Instead of running `upgrade.sh`, run one of the following sets of commands from the NetBox installation path. ### Python 2 ``` sudo pip install -r requirements.txt --upgrade python netbox/manage.py migrate python netbox/manage.py collectstatic --no-input ``` ### Python 3 ``` sudo pip3 install -r requirements.txt --upgrade python3 netbox/manage.py migrate python3 netbox/manage.py collectstatic --no-input ```
Author
Owner

@jeremystretch commented on GitHub (Jun 9, 2017):

I've updated the script to a) only use Python3 if both python3 and pip3 are available, and b) allow the user to force Python2 by running ./upgrade.sh -2. Hopefully this will mitigate any similar issues in the next release.

@jeremystretch commented on GitHub (Jun 9, 2017): I've updated the script to a) only use Python3 if both `python3` _and_ `pip3` are available, and b) allow the user to force Python2 by running `./upgrade.sh -2`. Hopefully this will mitigate any similar issues in the next release.
Author
Owner

@lucianopm commented on GitHub (Jun 9, 2017):

Thank you @jeremystretch

@lucianopm commented on GitHub (Jun 9, 2017): Thank you @jeremystretch
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1017