-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Permission denied error to install pkg editable and user mode #3019
Comments
Hi @jinserk, thank you very much for submitting this issue. |
Also, what would be your output for the command |
Thanks @abravalheri . Here is the log file using verbose option:
and the result of site.USER_SITE:
|
Hi @jinserk, thank you very much for providing the logs. Unfortunately pip does not help a lot by hiding the stack trace of the error 😞 Meanwhile if you need to carry on with your work, please consider using an editable install inside a virtual environment. |
Thank you very much for the reference @hexagonrecursion, I still haven't had the time to dive into the issue, but this link will definitely be useful! |
I have found a workaround: import site
site.ENABLE_USER_SITE=True
from setuptools import setup
setup() I do not know why ENABLE_USER_SITE is false when |
setuptools/setuptools/command/easy_install.py Lines 272 to 277 in 00fbad0
|
@hexagonrecursion thank you very much for investigating that and solving it! |
What PR? I'll open one once I have figured out how to fix it. For now I only know how to hack around the issue and even then I am not sure that my hack works properly. I am, havever, making progress towards uncovering the root cause. |
sys.flags.no_user_site is true for some reason def check_enableusersite():
...
if sys.flags.no_user_site:
# I inserted a print statement here while debugging
return False
...
...
def main():
global ENABLE_USER_SITE
...
if ENABLE_USER_SITE is None:
ENABLE_USER_SITE = check_enableusersite()
... |
two questions for tomorrow me:
|
A bug in pip or possibly setuptools broke editable installs into the per-user directory for packages that have pyproject.toml See pypa/setuptools#3019
I have excluded pip and reduced it to:
60.9.3 ENABLE_USER_SITE=False no_user_site=1
running develop
/usr/local/lib/python3.9/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
WARNING: The user site-packages directory is disabled.
/usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python3.9/site-packages/test-easy-install-3144.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python3.9/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://setuptools.pypa.io/en/latest/deprecated/easy_install.html
Please make the appropriate changes for your system and try again. setup.pyimport site
import sys
import setuptools
print(f"{setuptools.__version__} ENABLE_USER_SITE={site.ENABLE_USER_SITE!r} no_user_site={sys.flags.no_user_site!r}")
setuptools.setup() |
pip is innocent: we hide the stack ourselves: setuptools/setuptools/command/easy_install.py Lines 483 to 484 in e309995
|
I have figured out the pip side of the equation: PYTHONNOUSERSITE is set to 1 causing sys.flags.no_user_site = 1 in setup.py os.environ.update(
{
"PATH": os.pathsep.join(path),
"PYTHONNOUSERSITE": "1",
"PYTHONPATH": os.pathsep.join(pythonpath),
}
) Note: this is only true if you have |
Summary of my debugging so far:
pip install -e . without pyproject.toml{
"path": [
"",
"/usr/lib64/python39.zip",
"/usr/lib64/python3.9",
"/usr/lib64/python3.9/lib-dynload",
"/home/user/.local/lib/python3.9/site-packages",
"/usr/local/lib/python3.9/site-packages",
"/usr/lib64/python3.9/site-packages",
"/usr/lib/python3.9/site-packages",
"/home/user/hello/no-pro"
],
"argv": [
"/home/user/hello/no-pro/setup.py",
"egg_info",
"--egg-base",
"/tmp/pip-pip-egg-info-twrrxz0k"
]
}
{
"path": [
"",
"/usr/lib64/python39.zip",
"/usr/lib64/python3.9",
"/usr/lib64/python3.9/lib-dynload",
"/home/user/.local/lib/python3.9/site-packages",
"/usr/local/lib/python3.9/site-packages",
"/usr/lib64/python3.9/site-packages",
"/usr/lib/python3.9/site-packages",
"/home/user/hello/no-pro"
],
"argv": [
"/home/user/hello/no-pro/setup.py",
"develop",
"--no-deps",
"--user",
"--prefix="
]
}
pip install -e . with pyproject.toml{
"path": [
"/usr/lib/python3.9/site-packages/pip/_vendor/pep517",
"/tmp/pip-build-env-5z25jrps/site",
"/usr/lib64/python39.zip",
"/usr/lib64/python3.9",
"/usr/lib64/python3.9/lib-dynload",
"/tmp/pip-build-env-5z25jrps/overlay/lib/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/overlay/lib64/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/normal/lib/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/normal/lib64/python3.9/site-packages"
],
"argv": [
"/usr/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py",
"egg_info"
]
}
{
"path": [
"/usr/lib/python3.9/site-packages/pip/_vendor/pep517",
"/tmp/pip-build-env-5z25jrps/site",
"/usr/lib64/python39.zip",
"/usr/lib64/python3.9",
"/usr/lib64/python3.9/lib-dynload",
"/tmp/pip-build-env-5z25jrps/overlay/lib/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/overlay/lib64/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/normal/lib/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/normal/lib64/python3.9/site-packages"
],
"argv": [
"/usr/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py",
"dist_info",
"--egg-base",
"/tmp/pip-modern-metadata-0a_ne5zk"
]
}
{
"path": [
"",
"/tmp/pip-build-env-5z25jrps/site",
"/usr/lib64/python39.zip",
"/usr/lib64/python3.9",
"/usr/lib64/python3.9/lib-dynload",
"/tmp/pip-build-env-5z25jrps/overlay/lib/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/overlay/lib64/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/normal/lib/python3.9/site-packages",
"/tmp/pip-build-env-5z25jrps/normal/lib64/python3.9/site-packages",
"/home/user/hello/pro"
],
"argv": [
"/home/user/hello/pro/setup.py",
"develop",
"--no-deps",
"--user",
"--prefix="
]
} setup.pyimport sys
import json
with open('log.txt', 'a') as log:
o = {
"path":sys.path,
"argv":sys.argv,
}
json.dump(o, log)
import setuptools
setuptools.setup() pyproject.toml[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta" The planBuild isolation is good. We should probably keep it. I will try to understand how and why easy_install decides where to install packages. Possible fix ideas:
|
Related:
|
I absolutely don't remember, this happened 12 years ago on bit bucket when it still supported mercurial, and it was on distribute prior to the re merge of the 2 |
Thanks @hexagonrecursion @jaraco for addressing this! Just for completeness I'll mention that you're still "stuck" right now if you don't have root on your machine and system installed This will hopefully resolve itself soon as Linux distributions "catch up". |
Can use pyproject.toml to install in editable mode for this version of setuptools (pypa/setuptools#3019 (comment))
setuptools version
60.5.0
Python version
3.10.1
OS
Archlinux
Additional environment information
No response
Description
When I install a custom package with pip in user mode and editable, it produces permission denied error:
Expected behavior
Install the package into
$HOME/.local/lib/python3.10/site-packages
How to Reproduce
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: