1

I installed a python package (django) using sudo apt-get install python-django. Now I want to upgrade to the latest version.

Should I run sudo pip install -U django, or should I uninstall first the python-django installed with apt-get?

a06e
  • 13,223
  • 26
  • 70
  • 104

1 Answers1

0

sudo apt-get install python-django installs django in /usr/lib/python2.7/dist-packages while sudo pip install -U django installs django in /usr/local/lib/python2.7/dist-packages. This means you cannot upgrade Django installed by APT using pip and vice versa.

The latest version of django is unlikely to be provided by the official Ubuntu repositories. Therefore, I would suggest you uninstall the django that is installed using apt-get and then either use pip install --user django to install django locally or use virtual environments such as virtualenv to manage your Python dependencies. I would discourage you from using sudo pip install django because it is a security risk to use sudo to install arbitrary Python packages from PyPI which does not check for malicious packages; you can read more about this from an answer I wrote regarding this issue.

edwinksl
  • 23,789