python - pynput 安装在 python 2.7 中失败

标签 python pip

我尝试通过执行 pip install pynput 来安装 pynput。 它在 pyobjc-core-2.5.1 中抛出错误。它尝试卸载并安装包,但抛出异常。

pip install pynput
Collecting pynput
  Using cached pynput-1.3.5-py2.py3-none-any.whl
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pynput)
Requirement already satisfied: enum34; python_version == "2.7" in /Library/Python/2.7/site-packages (from pynput)
Collecting pyobjc-framework-Quartz>=3.0; sys_platform == "darwin" (from pynput)
  Using cached pyobjc_framework_Quartz-3.2.1-cp27-cp27m-macosx_10_6_intel.whl
Collecting pyobjc-core>=3.2.1 (from pyobjc-framework-Quartz>=3.0; sys_platform == "darwin"->pynput)
  Using cached pyobjc_core-3.2.1-cp27-cp27m-macosx_10_6_intel.whl
Collecting pyobjc-framework-Cocoa>=3.2.1 (from pyobjc-framework-Quartz>=3.0; sys_platform == "darwin"->pynput)
  Using cached pyobjc_framework_Cocoa-3.2.1-cp27-cp27m-macosx_10_6_intel.whl
Installing collected packages: pyobjc-core, pyobjc-framework-Cocoa, pyobjc-framework-Quartz, pynput
  Found existing installation: pyobjc-core 2.5.1
    Uninstalling pyobjc-core-2.5.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
    copytree(src, real_dst, symlinks=True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 208, in copytree
    raise Error, errors
Error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppCategories.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppCategories.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppCategories.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppCategories.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppCategories.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppCategories.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppHelper.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppHelper.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppHelper.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppHelper.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppHelper.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/AppHelper.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Conversion.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Conversion.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Conversion.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Conversion.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Conversion.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Conversion.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Debugging.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Debugging.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Debugging.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Debugging.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Debugging.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Debugging.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/FndCategories.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/FndCategories.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/FndCategories.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/FndCategories.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/FndCategories.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/FndCategories.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/KeyValueCoding.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/KeyValueCoding.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/KeyValueCoding.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/KeyValueCoding.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/KeyValueCoding.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/KeyValueCoding.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/MachSignals.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/MachSignals.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/MachSignals.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/MachSignals.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/MachSignals.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/MachSignals.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/NibClassBuilder.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/NibClassBuilder.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/NibClassBuilder.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/NibClassBuilder.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/NibClassBuilder.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/NibClassBuilder.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Signals.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Signals.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Signals.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Signals.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Signals.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/Signals.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/TestSupport.py', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/TestSupport.py', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/TestSupport.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/TestSupport.pyc', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/TestSupport.pyc', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/TestSupport.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools', '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools', "[Errno 1] Operation not permitted: '/var/folders/hd/p6kgn6zx2q98dhht353zy1ph0000gn/T/pip-sP_xhJ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools'")]

最佳答案

我使用的是 macOS Sierra 版本 10.12.6,据我所知,这是 OS X El Capitan 发布后的一个常见问题,至少在 Mac 平台上是这样。

发生的事情基本上是你触发了一个叫做 System Integrity Protection 的东西。内置于操作系统本身,这可以防止根文件系统的某些路径被修改——即使是根用户。因此,使用 sudo 也不起作用。

使用 pip,您可以在命令中包含标志 --user 并将文件安装到您的主目录以解决此问题。因此,尝试执行命令 pip install pynput --user

有关更多信息,请考虑查看此 article .

关于python - pynput 安装在 python 2.7 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44919679/

相关文章:

pip - 升级所有过时的 pip 包丢弃失败

python - 这个(冗余?)python 表达式的含义是什么?

python - 预期输入有 4 个维度,但得到的数组形状为 (32, 549, 1)

python - 调用参数中包含星号和名称的 Python 函数

python - 使用 Pip 1.5 安装外部的、未验证的包

python - 为什么不推荐使用 setup.py 中的依赖链接?

python - 找不到已安装的 pip 包

gcc - Dockerfile 构建 distutils.errors.DistutilsExecError : command 'gcc' failed with exit status 1

python - 识别 Pandas DataFrame 中每一行的第一个和所有非零值

python - 将特定位置的字符串替换成文本,然后重写所有文本