easy_install3 pip versus apt-get install python3-pip

55 views
Skip to first unread message

Brian Candler

unread,
Nov 14, 2018, 8:28:57 AM11/14/18
to NetBox
A minor question.

In the instructions for installation and for migrating to python3, it says to do "easy_install3 pip" instead of "apt-get install python3-pip"

Can someone explain why?  Is there a problem with the Ubuntu python3-pip package?

Thanks,

Brian.

Jeremy Stretch

unread,
Nov 14, 2018, 9:14:51 AM11/14/18
to Brian Candler, netbox-...@googlegroups.com
The repo version of pip is typically pretty outdated. That said, you should have no problem installing pip either via either method and upgrading with `pip install -U pip`

Jeremy

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/5b0de07a-73b7-412a-be22-17758570f3be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Candler

unread,
Nov 15, 2018, 9:49:47 AM11/15/18
to NetBox
Thanks for that.  My "old" version of pip was working fine, but I've upgraded it now.

I have an idea to help Netbox users run on python3.  The Ubuntu "supervisor" package depends on python2, so installs a bunch of python2 crud as dependencies.  I'd like to suggest that the Netbox install instructions are changed to show creating a systemd unit instead.

The following works for me.  Create a unit file /etc/systemd/system/netbox.service:

[Unit]
Description=Netbox - IP address management (IPAM) and data center infrastructure management (DCIM) tool
After=network-online.target
Wants=network-online.target
Conflicts=shutdown.target

[Service]
User=www-data
ExecStart=/usr/local/bin/gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
WorkingDirectory=/opt/netbox/netbox
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Then activate it:

systemctl daemon-reload
systemctl start netbox
systemctl enable netbox

With this approach, supervisord is no longer required. 

Brian Candler

unread,
Nov 27, 2018, 4:39:20 AM11/27/18
to NetBox
There is a minor problem when you upgrade pip this way:

...
You are using pip version 8.1.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@netbox:/opt/netbox# pip3 install --upgrade pip
Collecting pip
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed pip-18.1
root@netbox:/opt/netbox# pip3 --version
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

Oops.  Looks pip3 is broken.  But actually it isn't:

root@netbox:/opt/netbox# which pip3
/usr/local/bin/pip3
root@netbox:/opt/netbox# ls -l /usr/local/bin/pip*
-rwxr-xr-x 1 root root 215 Nov 27 09:32 /usr/local/bin/pip
-rwxr-xr-x 1 root root 214 Nov 14 14:48 /usr/local/bin/pip2
-rwxr-xr-x 1 root root 214 Nov 14 14:48 /usr/local/bin/pip2.7
-rwxr-xr-x 1 root root 215 Nov 27 09:32 /usr/local/bin/pip3
-rwxr-xr-x 1 root root 215 Nov 27 09:32 /usr/local/bin/pip3.5
root@netbox:/opt/netbox# /usr/local/bin/pip3 --version
pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)

It's just that the shell has cached the path /usr/bin/pip3.  After exiting and logging back in again, it's fine:

root@netbox:/opt/netbox# pip3 --version
pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
Reply all
Reply to author
Forward
0 new messages