python - 如何在 Mac OS X 10.11 上安装 Paramiko

标签 python macos paramiko

我尝试在 Mac OS X 10.11 上安装 paramiko

sudo pip install paramiko

Password:*******

然后我得到了

The directory '/Users/bheng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/bheng/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting paramiko
  Downloading paramiko-2.0.2-py2.py3-none-any.whl (171kB)
    100% |████████████████████████████████| 174kB 6.7MB/s 
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /Library/Python/2.7/site-packages (from paramiko)
Collecting cryptography>=1.1 (from paramiko)
  Downloading cryptography-1.5.2-cp27-cp27m-macosx_10_10_intel.whl (2.4MB)
    100% |████████████████████████████████| 2.4MB 568kB/s 
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography>=1.1->paramiko)
Collecting setuptools>=11.3 (from cryptography>=1.1->paramiko)
  Downloading setuptools-28.0.0-py2.py3-none-any.whl (467kB)
    100% |████████████████████████████████| 471kB 2.7MB/s 
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from cryptography>=1.1->paramiko)
Collecting idna>=2.0 (from cryptography>=1.1->paramiko)
  Downloading idna-2.1-py2.py3-none-any.whl (54kB)
    100% |████████████████████████████████| 61kB 10.4MB/s 
Collecting ipaddress (from cryptography>=1.1->paramiko)
  Downloading ipaddress-1.0.17-py2-none-any.whl
Collecting enum34 (from cryptography>=1.1->paramiko)
  Downloading enum34-1.1.6-py2-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=1.4.1->cryptography>=1.1->paramiko)
Installing collected packages: setuptools, idna, ipaddress, enum34, cryptography, paramiko
  Found existing installation: setuptools 1.1.6
    Uninstalling setuptools-1.1.6:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/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/_markerlib/__init__.py', '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/tmp/pip-EMyxYY-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]

我做错了什么?

最佳答案

尝试sudo chown $(whoami) /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/ 然后对 Python 无权访问的任何目录执行相同的操作。

最新版本的 OSX 和 macOS 有一个名为系统完整性保护的系统,这意味着某些目录没有用户权限。这是为了防止恶意软件控制系统中央目录的可能性,例如 /System/tmp .

编辑

pip install --user paramiko将库安装在用户目录下,这意味着您不会遇到权限问题。还有其他方法可以使用 Python 一致地解决此问题,请参阅本文的评论了解更多信息。

关于python - 如何在 Mac OS X 10.11 上安装 Paramiko,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39799891/

相关文章:

python - Gtk +3 TextView 应用程序崩溃

python - SSL错误 : Not a directory

macos - 无论 bash 脚本的默认应用程序设置为什么,在终端 (Mac) 中打开一个 shell 脚本

python - 如何使用 Paramiko 获取 SSH 返回码?

python - Paramiko ssh exec_command 用于来自 Windows 客户端的 IPv6 服务器

python - 在 Dataframe 中递归引用行

python - 如何在uwsgi上指定命名空间或后缀?

python - 无法在 OS X 10.8.5 上安装 lxml

python - paramiko 允许没有 key 的 sftp 连接

python - 如何并行安装/编译 pip 要求(使 -j 等效)