Pip: Cannot install into user site directory with editable source.

Created on 1 Apr 2020  路  10Comments  路  Source: pypa/pip

In build_env.py the environment variable PYTHONNOUSERSITE is set: https://github.com/pypa/pip/blob/7b02273f3e40aaab95027d5d560bd8e76ab623e4/src/pip/_internal/build_env.py#L127

This prevents editable installs with PYTHONUSERBASE=<some-user-base> pip3.8 install --user -e <some-file-path> from succeeding if the user does not have write access to the base-Python site-packages directory.

This is a snapshot of the error.

running develop
    WARNING: The user site-packages directory is disabled.
    error: can't create or remove files in install directory

It may be that it is a deliberate design choice to disable editable installs under a user site directory. I personally needed this feature, however, and I am therefore setting site.ENABLE_USER_SITE = True in setup.py as a workaround.

triage

Most helpful comment

@ssbarnea PEP 517 doesn't support editable installs, so I don't see how PEP 517 is relevant here?

I don't know, but doing a

pip install --user --no-use-pep517 -e .

succeeds, and after that a

pip install --user -e .

doesn't fail anymore. However, this still fails:

pip install --user --force-reinstall -e .

All 10 comments

This affects the pipenv local build instructions in https://pipenv.pypa.io/en/latest/dev/contributing/#development-setup:

  • pip3 install -e . doesn't work as the global site-packages isn't writable by regular users
  • pip3 install --user -e . doesn't work due to pip indicating the user site directory is disabled

I'm adapting @agoose77's workaround into a PIPENV_BOOTSTRAP=1 environment variable.

Ran into this today on debian 9, not sure what has changed but we have been using pip3 install --user -e . for a long time for development purposes, it is strange for this to suddenly stop working.

Seeing this on macOS as well.

I have seen this failing for a project that uses pyproject.toml (PEP517 install flow), where it works fine for projects without pyproject.toml. @siddalmia has described the same behavior in https://github.com/pytorch/fairseq/issues/1977. I wonder if there is something in the PEP517 install flow that breaks this...?

@tgpfeiffer, please see the discussion on Discourse for more information. Aside from setup.py develop, another work around for packages with __main__.py is to run it directly, e.g. for pip: python src/pip.

Following the tip from @agoose77, I'm putting this in my setup.py as a workaround:

import site
import sys
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
...

Nobody was able to fix this in pip? The whole idea of pep517 was to reduce use of setup.py ending in its removal, not adding more junk into to it.

@ssbarnea PEP 517 doesn't support editable installs, so I don't see how PEP 517 is relevant here?

@pfmoore you can support an editable install in a project using PEP 517 by adding a rather minimal setup.py.

But then, it is impossible to have -e and --user

@ssbarnea PEP 517 doesn't support editable installs, so I don't see how PEP 517 is relevant here?

I don't know, but doing a

pip install --user --no-use-pep517 -e .

succeeds, and after that a

pip install --user -e .

doesn't fail anymore. However, this still fails:

pip install --user --force-reinstall -e .
Was this page helpful?
0 / 5 - 0 ratings