FYI, there's a really nasty problem if you install netbox under ubuntu 16.04 with python 3, and then follow the instructions at
https://netbox.readthedocs.io/en/stable/installation/web-server/ which say to do
apt-get install -y gunicorn supervisor
Actually you need to install "gunicorn3" not "gunicorn".
If you try to install "gunicorn" then get into a horribly broken state:
# apt-get install -y gunicorn supervisor
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python-gunicorn python-meld3
python-minimal python-pkg-resources python-setuptools python2.7 python2.7-minimal
Suggested packages:
gunicorn-examples python-gevent python-pastedeploy python-setproctitle python-tornado
python-doc python-tk python-setuptools-doc python2.7-doc binfmt-support supervisor-doc
The following NEW packages will be installed:
gunicorn libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python-gunicorn
python-meld3 python-minimal python-pkg-resources python-setuptools python2.7 python2.7-minimal
supervisor
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,575 kB of archives.
After this operation, 19.7 MB of additional disk space will be used.
...
Preparing to unpack .../python_2.7.11-1_amd64.deb ...
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/python3 because link group python is broken
Unpacking python (2.7.11-1) ...
...
Setting up python (2.7.11-1) ...
Setting up python-pkg-resources (20.7.0-1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-pkg-resources (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-setuptools:
python-setuptools depends on python-pkg-resources (= 20.7.0-1); however:
Package python-pkg-resources is not configured yet.
dpkg: error processing package python-setuptools (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-gunicorn:
python-gunicorn depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
python-gunicorn depends on python-setuptools; however:
Package python-setuptools is not configured yet.
dpkg: error processing package python-gunicorn (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gunicorn:
gunicorn depends on python-gunicorn (= 19.4.5-1ubuntu1); however:
Package python-gunicorn is not configured yet.
gunicorn depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
gunicorn depends on python-setuptools; however:
Package python-setuptools is not confNo apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached already
igured yet.
dpkg: error processing package gunicorn (--configure):
dependency problems - leaving unconfigured
Setting up python-meld3 (1.0.2-2) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-meld3 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of supervisor:No apport report written because MaxReports is reached already
supervisor depends on python-meld3; however:
Package python-meld3 is not configured yet.
supervisor depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
dpkg: error processing package supervisor (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Errors were encountered while processing:
python-pkg-resources
python-setuptools
python-gunicorn
gunicorn
python-meld3
supervisor
E: Sub-process /usr/bin/dpkg returned an error code (1)
At this point, attempts to remove the broken packages also fail:
# apt-get remove --purge gunicorn supervisor
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-gunicorn python-meld3 python-pkg-resources python-setuptools
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
gunicorn* supervisor*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
6 not fully installed or removed.
After this operation, 1,450 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 102594 files and directories currently installed.)
Removing gunicorn (19.4.5-1ubuntu1) ...
Purging configuration files for gunicorn (19.4.5-1ubuntu1) ...
Removing supervisor (3.2.0-2ubuntu0.1) ...
Purging configuration files for supervisor (3.2.0-2ubuntu0.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-pkg-resources (20.7.0-1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-pkg-resources (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-setuptools:
python-setuptools depends on python-pkg-resources (= 20.7.0-1); however:
Package python-pkg-resources is not configured yet.
dpkg: error processing package python-setuptools (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-gunicorn:
python-gunicorn depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
python-gunicorn depends on python-setuptools; however:
Package python-setuptools is not configured yet.
dpkg: error processing package python-gunicorn (--configure):
dependency problems - leaving unconfigured
Setting up python-meld3 (1.0.2-2) ...
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-meld3 (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
python-pkg-resources
python-setuptools
python-gunicorn
python-meld3
E: Sub-process /usr/bin/dpkg returned an error code (1)
# apt-get autoremove --purge
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
python-gunicorn* python-meld3* python-pkg-resources* python-setuptools*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 1,570 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 102460 files and directories currently installed.)
Removing python-gunicorn (19.4.5-1ubuntu1) ...
Purging configuration files for python-gunicorn (19.4.5-1ubuntu1) ...
Removing python-meld3 (1.0.2-2) ...
File "/usr/bin/pyclean", line 63
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing package python-meld3 (--purge):
subprocess installed pre-removal script returned error exit status 1
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 1
Removing python-setuptools (20.7.0-1) ...
Removing python-pkg-resources (20.7.0-1) ...
File "/usr/bin/pyclean", line 63
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing package python-pkg-resources (--purge):
subprocess installed pre-removal script returned error exit status 1
Errors were encountered while processing:
python-meld3
python-pkg-resources
E: Sub-process /usr/bin/dpkg returned an error code (1)
# dpkg-query -l | grep meld
pF python-meld3 1.0.2-2 all HTML/XML templating system for Python
# dpkg-query -l | grep python-pkg-resources
pF python-pkg-resources 20.7.0-1 all Package Discovery and Resource Access using pkg_resources
So I put it back using:
update-alternatives --install /usr/bin/python python /usr/bin/python2 2
apt-get remove --purge python-meld3 python-pkg-resources
and indeed, now the package removal was successful.
Then I repeated with:
update-alternatives --install /usr/bin/python python /usr/bin/python2 0
apt-get install -y gunicorn3 supervisor
Unfortunately I get a similar problem:
# apt-get install -y gunicorn3 supervisor
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python-meld3 python-pkg-resources python3-gunicorn
Suggested packages:
gunicorn-examples python3-pastedeploy python3-setproctitle python3-tornado python-setuptools
supervisor-doc
The following NEW packages will be installed:
gunicorn3 python-meld3 python-pkg-resources python3-gunicorn supervisor
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 98.6 kB/491 kB of archives.
After this operation, 2,482 kB of additional disk space will be used.
Fetched 98.6 kB in 25s (3,821 B/s)
Selecting previously unselected package python3-gunicorn.
(Reading database ... 102296 files and directories currently installed.)
Preparing to unpack .../python3-gunicorn_19.4.5-1ubuntu1_all.deb ...
Unpacking python3-gunicorn (19.4.5-1ubuntu1) ...
Selecting previously unselected package gunicorn3.
Preparing to unpack .../gunicorn3_19.4.5-1ubuntu1_all.deb ...
Unpacking gunicorn3 (19.4.5-1ubuntu1) ...
Selecting previously unselected package python-pkg-resources.
Preparing to unpack .../python-pkg-resources_20.7.0-1_all.deb ...
Unpacking python-pkg-resources (20.7.0-1) ...
Selecting previously unselected package python-meld3.
Preparing to unpack .../python-meld3_1.0.2-2_all.deb ...
Unpacking python-meld3 (1.0.2-2) ...
Selecting previously unselected package supervisor.
Preparing to unpack .../supervisor_3.2.0-2ubuntu0.1_all.deb ...
Unpacking supervisor (3.2.0-2ubuntu0.1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu17) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up python3-gunicorn (19.4.5-1ubuntu1) ...
Setting up gunicorn3 (19.4.5-1ubuntu1) ...
Setting up python-pkg-resources (20.7.0-1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-pkg-resources (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-meld3 (1.0.2-2) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-meld3 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of supervisor:
supervisor depends on python-meld3; however:
Package python-meld3 is not configured yet.
supervisor depends on python-pkg-resources; however:
Package python-pkg-resources is not configured yet.
dpkg: error processing package supervisor (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
python-pkg-resources
python-meld3
supervisor
E: Sub-process /usr/bin/dpkg returned an error code (1)
The solution was to leave the alternative pointing at python2 during the installation of gunicorn3:
update-alternatives --install /usr/bin/python python /usr/bin/python2 2
apt-get remove --purge python-meld3 python-pkg-resources supervisor
dpkg-query -l | grep -v ^ii # confirms everything is OK
apt-get install -y gunicorn3 supervisor # this was successful
I wonder if it's better just to ignore the alternatives mechanism completely?
update-alternatives --remove python /usr/bin/python2
update-alternatives --remove python /usr/bin/python3
But for now I'll put it back to be in alignment with the netbox instructions:
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Regards,
Brian.