pip installs to /usr/lib/python-x.y/site-packages if PYTHONUSERBASE is set

Bug #1694560 reported by j00bar on 2017-05-30
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
python-pip (Ubuntu)
Undecided
Unassigned

Bug Description

If the environment variables PYTHONUSERBASE is set, regardless of what it's set to, pip3 will install packages to /usr/lib/python-x.y/site-packages, which isn't in the interpreter's default search path.

Big-Kahuna:~ jginsberg$ docker run -it --rm=true ubuntu:xenial bash
root@5fd4377b5952:/# apt-get update && apt-get -y install python3 python3-pip
(... snip ...)
root@5fd4377b5952:/# pip3 install django
Collecting django
  Downloading Django-1.11.1-py2.py3-none-any.whl (6.9MB)
    100% |################################| 7.0MB 262kB/s
Collecting pytz (from django)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |################################| 491kB 3.2MB/s
Installing collected packages: pytz, django
Successfully installed django-1.11.1 pytz-2017.2
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@5fd4377b5952:/# find . -type d -name django
./usr/local/lib/python3.5/dist-packages/django
./usr/local/lib/python3.5/dist-packages/django/forms/jinja2/django
./usr/local/lib/python3.5/dist-packages/django/forms/templates/django
root@5fd4377b5952:/# exit
Big-Kahuna:~ jginsberg$ docker run -it --rm=true ubuntu:xenial bash
root@446d9529fb6c:/# export PYTHONUSERBASE=/yourmom
root@446d9529fb6c:/# apt-get update && apt-get -y install python3 python3-pip
(... snip ...)
root@446d9529fb6c:/# pip3 install Django
Collecting Django
  Downloading Django-1.11.1-py2.py3-none-any.whl (6.9MB)
    100% |################################| 7.0MB 240kB/s
Collecting pytz (from Django)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |################################| 491kB 1.3MB/s
Installing collected packages: pytz, Django
Successfully installed Django pytz
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root@446d9529fb6c:/# find . -type d -name django
./usr/lib/python3.5/site-packages/django
./usr/lib/python3.5/site-packages/django/forms/jinja2/django
./usr/lib/python3.5/site-packages/django/forms/templates/django
root@446d9529fb6c:/#

j00bar (jag) wrote :

Based on this comment: https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1308714/comments/8 this seems related to #1308714.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-pip (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers