python watchdog 使用时报错_尝试使用pip安装看门狗时如何解决“错误:退出状态为1的命令错误”...

I am revisiting the python language and experiencing difficulty setting up my environment.

I am using

- Mac Mojave (10.14)

- python 2.7.10 (packaged with the system)

- python 3.7.4 (installed using homebrew)

- homebrew 2.1.14

- pip 19.2.3

I encounter an error message when attempting to install watchdog via pip. I believe the error is caused by pip attempting to install in python 2.7 folders (without sufficient permissions) instead of the python 3 folder

I have tried uninstalling, reinstalling and upgrading python 3

I encounter the following error message when attempting to install watchdog via pip

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.

解决方案

When you run pip install, exactly which pip gets used depends on several things like your PATH, shell, shell configuration, and operating system.

The best thing to do is invoke pip using -m pip where is the Python that you want to install the package for. For example, if you run python3 to use the Python that you want to install the package for, then run python3 -m pip.

If you're running python3 -m pip install ... and getting permission errors, then you can execute python3 -m pip install --user ..., which will install it to your user site-packages directory and available when you execute python3 under your user.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值