How to fix ‘“ERROR: Command errored out with exit status 1:” when trying to install watchdog using pip

How to fix ‘“ERROR: Command errored out with exit status 1:” when trying to install watchdog using pip

我正在重新访问 python 语言并且在设置我的环境时遇到困难。

我正在使用 - Mac 莫哈韦沙漠 (10.14) - python 2.7.10(随系统打包) - python 3.7.4(使用自制软件安装) - 自制软件 2.1.14 - 点 19.2.3

我在尝试通过 pip 安装 watchdog 时遇到错误消息。我认为错误是由于 pip 试图安装在 python 2.7 文件夹(没有足够的权限)而不是 python 3 文件夹

我试过卸载、重新安装和升级python3

我在尝试通过 pip 安装 watchdog 时遇到以下错误消息

 1 error generated.
    Error compiling module, falling back to pure Python
    running install_lib
    creating /Library/Python/2.7/site-packages/yaml
    error: could not create '/Library/Python/2.7/site-packages/yaml': Permission denied
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/4d/spq3r5t92654252ql994_l540000gr/T/pip-install-nqmq6O/PyYAML/setup.py'"'"'; __file__='"'"'/private/var/folders/4d/spq3r5t92654252ql994_l540000gr/T/pip-install-nqmq6O/PyYAML/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/4d/spq3r5t92654252ql994_l540000gr/T/pip-record-g8Qjzh/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

当您 运行 pip install 时,具体使用哪个 pip 取决于几个因素,例如您的 PATH、shell、shell配置和操作系统。

最好的办法是使用 <python> -m pip 调用 pip,其中 <python> 是您要为其安装软件包的 Python。例如,如果您 运行 python3 使用要为其安装软件包的 Python,则 运行 python3 -m pip.

如果您正在 运行 宁 python3 -m pip install ... 并遇到权限错误,那么您可以执行 python3 -m pip install --user ...,这会将其安装到您的用户站点包目录,并在您使用时可用在你的用户下执行python3

您需要升级 setuptools 和 pip。您可以通过 运行:

pip install -U pip setuptools