How Do You Install the Latest Version of python-setuptools (aka easy_install) when Your Package Repositories Do Not Have It Available?

Problem scenario
Your apt or yum repositories do not have the newest version of python-setuptools (aka easy_install) available.  You need to install a recent version.  What should you do?

Solution
Prerequisites
a.  You need to have unzip installed.  Debian/Ubuntu servers usually have this by default, but if you still need assistance, see the Debian/Ubuntu link below.  Click on your distribution of Linux for assistance with installing unzip:
CentOS/RHEL/Fedora
Debian/Ubuntu
SUSE
b.  If the server is completely new, we recommend uninstalling python-setuptools.  If you have installed Docker or other tools that rely on python-setuptools, we do not recommend uninstalling python-setuptools as it is a dependency to other packages.  If you do remove python-setuptools, the first command in step #3 below will return an error.

Procedures
1.  If you need to upgrade python-setuptools on a Linux server you can download the zip file from here.  If you have access to the internet, run this command (but substitute the URL with the desired .zip file on the page that is hyperlinked earlier and replace "file.zip" with the name of the file that you are downloading): curl -Lk http://pypi.org/path/to/file.zip > /tmp/file.zip
2.  Copy the .zip file to the /bin/ directory: sudo mv /tmp/file.zip /bin
3.  Run these commands:
sudo mv /bin/easy_install ~
cd /bin
sudo unzip nameOfFileabove.zip
cd setuptools   #then press tab to autocomplete
sudo python setup.py build
sudo python setup.py install

4.  You should be done.  To test your version of easy_install (which is the same as python-setuptools), run this command:
easy_install --version
For the sake of a proof-of-concept, provided you are not in a sensitive environment, you can ignore a message "ImportError: No module named py31compat".  Otherwise you may want to address this message.

Leave a comment

Your email address will not be published. Required fields are marked *