1

I want to change the default installation path of pip.

ENV PIP_TARGET=/jup/site-packages\
    PYTHONPATH="${PYTHONPATH}:/jup/site-packages"

When I run pip install everything is installed in jup/site-packages. This works fine. pip list also returns the correct packages.

However, when I run pip install again, the packages get installed again and I get a warning that the target directory already exists:

WARNING: Target directory /jup/site-packages/numpy already exists. Specify --upgrade to force replacement.

I would expect to not do the installation again with the message that the package is already installed. `

(app-root) bash-4.4# python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
/opt/app-root/lib/python3.9/site-packages

I seems that Python still looks in the wrong directory for packages. How can I fix this?

Data Mastery
  • 1,555
  • 4
  • 18
  • 60
  • This is a [bug in in pip](https://github.com/pypa/pip/issues?q=is%3Aopen+is%3Aissue+label%3A%22C%3A+target%22). The PYTHONUSERBASE variable mentioned in answer is unrelated, and doesn't solve the issue. – wim May 24 '22 at 15:46
  • @wim: Ok then why do I not get an error after setting it? – Data Mastery May 24 '22 at 17:50
  • Don't know, I can not reproduce that - the error remains the same (tried on two different machines) – wim May 24 '22 at 18:43

0 Answers0