我正在尝试使用pip
以--editable
模式安装本地软件包。当我输入以下命令时...
$ python3.7 -m pip install --user -e /home/me/my_pkg/
...当它正确安装所有依赖项后,尝试安装my_pkg
本身时,我遇到了以下问题...
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'
我不明白为什么使用--user
标志后会出现权限错误。我不想全局安装此软件包,因此不能使用sudo pip install ...
。如何让pip只为当前用户安装一个editable
软件包?
$ python3.7 -m pip --version
pip 21.1.1 from /home/rob/.local/lib/python3.7/site-packages/pip (python 3.7)
~/.dbus
,我已经修复了它,但它并没有改变行为。不过这是个好建议。 - reynoldsnlpecho $PYTHONNOUSERSITE
? - phd