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'
What version of Python are you running NetBox on?
root@netbox:/opt/netbox# python3 --version
Python 3.5.2
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):
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.
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.
sudo pip install -r requirements.txt --upgrade
python netbox/manage.py migrate
python netbox/manage.py collectstatic --no-input
sudo pip3 install -r requirements.txt --upgrade
python3 netbox/manage.py migrate
python3 netbox/manage.py collectstatic --no-input
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.
Thank you @jeremystretch
Most helpful comment
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
Python 3