Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError when upgrading to 2.0.5 using upgrade.sh #1253

Closed
lucianopm opened this issue Jun 8, 2017 · 7 comments
Closed

ImportError when upgrading to 2.0.5 using upgrade.sh #1253

lucianopm opened this issue Jun 8, 2017 · 7 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@lucianopm
Copy link

lucianopm commented 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'
@jeremystretch
Copy link
Member

What version of Python are you running NetBox on?

@lucianopm
Copy link
Author

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

@lampwins
Copy link
Contributor

lampwins commented 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):

@jeremystretch
Copy link
Member

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

@jeremystretch jeremystretch changed the title Updating via GIT error ImportError when upgrading to 2.0.5 using upgrade.sh Jun 8, 2017
@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application and removed awaiting reply labels Jun 8, 2017
@jeremystretch
Copy link
Member

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
Copy link
Member

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.

@lucianopm
Copy link
Author

Thank you @jeremystretch

lampwins pushed a commit to lampwins/netbox that referenced this issue Oct 13, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants