pip: Cannot install into user site directory with editable source.
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.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 34
- Comments: 43 (16 by maintainers)
Commits related to this issue
- Workaround pip editable install bug Implements workaround for failure to install as editable on certain cases when --user is mentioned. Related: https://github.com/pypa/pip/issues/7953 — committed to ssbarnea/molecule by ssbarnea 4 years ago
- Workaround for github.com/pypa/pip/issues/7953 — committed to nebw/temporal_nmf by nebw 4 years ago
- * Add workaround to support `pip -e` (https://github.com/pypa/pip/issues/7953) * Fix exception when invalid strategy is specified — committed to jschwartzentruber/lithium by jschwartzentruber 4 years ago
- Workaround for editable installs Related: https://github.com/pypa/pip/issues/7953 — committed to ansible-community/molecule-vagrant by ssbarnea 4 years ago
- Workaround for pip failure to perform editable install (#55) Related: https://github.com/pypa/pip/issues/7953 — committed to ansible-community/molecule-vagrant by ssbarnea 4 years ago
- * Add workaround to support `pip -e` (https://github.com/pypa/pip/issues/7953) * Fix exception when invalid strategy is specified — committed to jschwartzentruber/lithium by jschwartzentruber 4 years ago
- Fix installation instructions see https://github.com/pypa/pip/issues/7953 — committed to gberaudo/scrumtools by gberaudo 4 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- Fix install scripts errors https://github.com/pypa/pip/issues/7953 https://github.com/pypa/pip/issues/9242 — committed to agardelein/textoter by agardelein 3 years ago
- adding hack to setup.py to fix editable install issue as described in https://github.com/pypa/pip/issues/7953\#issuecomment-645133255 — committed to dsavransky/grading by dsavransky 3 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- setup: Fix for pypa/pip#7953 Signed-off-by: John Andersen <johnandersenpdx@gmail.com> — committed to pdxjohnny/dffml by pdxjohnny 3 years ago
- [setup.py] Work around pip bug with "pip install -e ." See https://github.com/pypa/pip/issues/7953 — committed to behdad/fontmake by behdad 3 years ago
- [setup.py] Work around pip bug with "pip install -e ." See https://github.com/pypa/pip/issues/7953 — committed to googlefonts/fontmake by behdad 3 years ago
- Implement pip workaround for editable installs See: https://github.com/pypa/pip/issues/7953 — committed to ssbarnea/mk by ssbarnea 3 years ago
- Implement pip workaround for editable installs (#68) See: https://github.com/pypa/pip/issues/7953 — committed to pycontribs/mk by ssbarnea 3 years ago
Following the tip from @agoose77, I’m putting this in my
setup.pyas a workaround:I don’t know, but doing a
succeeds, and after that a
doesn’t fail anymore. However, this still fails:
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.
Another workaround is
--prefix=~/.localrather than--userI’ve been using the workaround mentioned in https://github.com/pypa/pip/issues/7953#issuecomment-645133255 for a while now:
but it stopped working recently.
The good news is that I don’t need that old workaround anymore with this new workaroud:
that I found here: https://github.com/pypa/setuptools/issues/3063#issuecomment-1026030252 (-- same workaround as in @mixmastamyk post https://github.com/pypa/pip/issues/7953#issuecomment-1027612802)
EDIT: I forgot about my own workaround here (in https://github.com/pypa/pip/pull/9990):
– it also works.
I have seen this failing for a project that uses
pyproject.toml(PEP517 install flow), where it works fine for projects withoutpyproject.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…?Hmm, I’ve been using this functionality for years. “We broke it and you are welcome to fix it” is not particularly neighborly.
How 'bout a link to the broken function or general ballpark?
P.S. This got me thru the install:
Ran into this again today. Very surprised, that this issue is still not fixed.
Hit this issue today trying out the currently-recommended way to package Python code for a new package. Everything works fine exclusively using the previously-recommended
setup.py, but trying to use asetup.cfgor even including apyproject.tomlresults in failing to install editable source. Unfortunate that this issue has been around for more than a year now…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.@pradyunsg
Not sure if this is a minimal example, probably not, but I don’t have the time to simplify this any further.
If I try
--no-use-pep517I getThe only workaround I’ve found so far is to “hide” pyproject.toml temporarily, like
While this feels a little gross, I guess this is “fine” in the sense that there isn’t much use for me having a pyproject.toml if I’m going to do an editable install anyway. I also suppose this means PEP517 might still be used for other packages that are dependencies, which would be a good thing.
the
setup.pyis deprecated and the new proposed way is not working at the same time. What should we do now? You should not mark it deprecated at least.Not in the sense that any of the pip maintainers is currently expecting to work on it, no. It’s simply a matter of too much work and not enough people, though - there’s no objection in principle to a fix.
We’re really relying on the possibility of someone who is actually affected by the issue having the time and willingness to contribute a fix, and we can’t really plan for when or if that might happen. That’s just the nature of open source, I’m afraid.
I also ran into this today. Is this intentionally not supported? I’m not sure why, I’d find it useful.
Raised bugs against distros shipping outdated setuptools:
@StanczakDominik the minimal reproducible example, that I provided earlier in this thread is still broken. Here it is, updated for the latest pip/python versions:
The
pip install --user --editable .fails with the following output:Seeing this on macOS as well.
Funnily enough, this seems to work for me after
pip install --upgrade pipgrabbing pip 22.0.3. Can anyone affected reproduce that? If so, could this issue be closed?Can the pip maintainers at least clarify, why is the user site being disabled in the first place?
From our (the users) perspective, it seems that the problem is that the user directory is disabled for some reason. As outlined in the OPs post, the fix can be as simple as removing the
'PYTHONNOUSERSITE': '1',line fromsrc/pip/_internal/build_env.py. However, this fix ignores the original reason for disabling the user install site. What was that reason?This isolation mechanism, was originally introduced in PR #4144 in commit 92bfdf702f2cc867f27e98d3eae1e930bdd25edc “Isolate wheel builds when using PEP 518 build dependencies”. My best guess is that
PYTHONNOUSERSITEis used so that the build dependencies are installed into the temporary prefix instead of the user site, but I am not 100% sure. One more thing that I don’t understand is why doessetuptools/easy_installtry to install the editable package during the build step.Also also, @pfmoore earlier in this thread you mentioned that PEP 517 doesn’t support editable installs. If my understanding is correct, this is no longer true after PEP 660 got accepted. Maybe, the actual problem here is that
setuptoolscurrently doesn’t implement PEP660 pypa/setuptools#2816?Issue still present with pip version
pip 21.1.2.I would encourage people affected by this to dig into the source. The code path described does not make much sense. The code path for an editable install should not go through
build_env.pyat all, so there is either a misidentification to the cause, or a more obscure bug than the sympton shows.Facing this with root installs into non-user directory on ubuntu 20 + python 3.8. Eaten a ton of my time.
I will take a look, but I don’t know, how pip internally works (e.g. why is that class only entered when
pyproject.tomlexists, why disabling the user install with an envvariable, why does the reset not work or is the actual installation done in that context, …).Not sure, if I am able to understand enough of pip in a reasonable time. If I get an idea how to fix it, I will open a PR.
You’re welcome to step up and fix this, because you clearly care enough to step up and complain that this hasn’t been fixed.
@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
-eand--user