I am trying to install local package in --editable
mode using pip
. When I issue the command...
$ python3.7 -m pip install --user -e /home/me/my_pkg/
...it correctly installs all of the dependencies, but then when it tries to install my_pkg
itself, I get the following...
Running setup.py develop for udar
Running command /usr/bin/python3.7 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/me/my_pkg/setup.py'"'"'; __file__='"'"'/home/me/my_pkg/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
running develop
WARNING: The user site-packages directory is disabled.
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.7/dist-packages/test-easy-install-901889.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python3.7/dist-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.readthedocs.io/en/latest/easy_install.html
Please make the appropriate changes for your system and try again.
ERROR: Command errored out with exit status 1: /usr/bin/python3.7 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/me/my_pkg/setup.py'"'"'; __file__='"'"'/home/me/my_pkg/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/base_command.py", line 180, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/req_command.py", line 204, in wrapper
return func(self, options, args)
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/commands/install.py", line 402, in run
pycompile=options.compile,
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/req/__init__.py", line 85, in install_given_reqs
pycompile=pycompile,
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/req/req_install.py", line 768, in install
unpacked_source_directory=self.unpacked_source_directory,
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/operations/install/editable_legacy.py", line 46, in install_editable
cwd=unpacked_source_directory,
File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/subprocess.py", line 244, in call_subprocess
raise InstallationSubprocessError(proc.returncode, command_desc)
pip._internal.exceptions.InstallationSubprocessError: Command errored out with exit status 1: /usr/bin/python3.7 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/me/my_pkg/setup.py'"'"'; __file__='"'"'/home/me/my_pkg/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
Removed build tracker: '/tmp/pip-req-tracker-hvg66sl4'
I don't understand how I can be getting a permission error with the --user
flag. I do not want to install this package globally, so using sudo pip install ...
is not an option. How do I get pip to install an editable
package for only the current user?
$ python3.7 -m pip --version
pip 21.1.1 from /home/rob/.local/lib/python3.7/site-packages/pip (python 3.7)
It's a bug. The issue is being tracked at https://github.com/pypa/pip/issues/7953 .
The workaround for now is to modify your setup.py()
to contain this:
import site
import sys
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
Or to use something like this on the command line, if you use setup.cfg or pyproject.toml:
$ python3 -c 'import setuptools, site, sys; site.ENABLE_USER_SITE = 1; sys.argv[1:] = ["develop", "--user"]; setuptools.setup()'
From the discussion linked by Clément (https://github.com/pypa/pip/issues/7953), the following works for me:
$ pip install --prefix=~/.local -e .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With