无法在 Cent 中安装 Paramiko OS

Can not install Paramiko in Cent OS

最近在努力学习python,在工作中写一些脚本。但是我发现我的 python 没有更新到最新。所以我按照网络上的一些指南从 2.6 升级到 2.7.6。之后 python、pip 和 easy_install 似乎一切正常。 然后我尝试使用 pip 安装 Paramiko。错误显示找不到 libffi,如下所示。但是,当我尝试安装 libffi 时,它显示已经存在。我试图搜索那里是否有其他包裹,但没有。

问题是 pip 试图找到 libffi.pc 但它不在任何包中。

谁能帮帮我?

谢谢!


[root@vmx-dsm-038 ~]# pip install paramiko
Requirement already satisfied (use --upgrade to upgrade): paramiko in /usr/local/lib/python2.7/site-packages/paramiko-2.0.0-py2.7.egg
Collecting cryptography>=1.1 (from paramiko)
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached cryptography-1.4.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /usr/local/lib/python2.7/site-packages (from paramiko)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /usr/local/lib/python2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/local/lib/python2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use --upgrade to upgrade): setuptools>=11.3 in /usr/local/lib/python2.7/site-packages/setuptools-22.0.5-py2.7.egg (from cryptography>=1.1->paramiko)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /usr/local/lib/python2.7/site-packages (from cryptography>=1.1->paramiko)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /usr/local/lib/python2.7/site-packages (from cryptography>=1.1->paramiko)
Collecting cffi>=1.4.1 (from cryptography>=1.1->paramiko)
  Using cached cffi-1.6.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography>=1.1->paramiko)
Building wheels for collected packages: cryptography, cffi
  Running setup.py bdist_wheel for cryptography ... error
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-TN9_mw/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpQ9VyZFpip-wheel- --python-tag cp27:
  Package libffi was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libffi.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libffi' found
  Package libffi was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libffi.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libffi' found
  Package libffi was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libffi.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libffi' found
  Package libffi was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libffi.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libffi' found
  Package libffi was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libffi.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libffi' found
  c/_cffi_backend.c:15:17: error: ffi.h: No such file or directory
  In file included from c/_cffi_backend.c:63:

[root@vmx-dsm-038 ~]# yum install libffi
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Setting up Install Process
Package libffi-3.0.5-3.2.el6.x86_64 already installed and latest version
Nothing to do

[root@vmx-dsm-038 ~]# yum search libffi
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
====================================================================================== N/S Matched: libffi ======================================================================================
libffi.i686 : A portable foreign function interface library
libffi.x86_64 : A portable foreign function interface library

  Name and summary matches only, use "search all" for everything.

[root@vmx-dsm-038 ~]# rpm -ql libffi.x86_64
/usr/lib64/libffi.so.5
/usr/lib64/libffi.so.5.0.6
/usr/share/doc/libffi-3.0.5
/usr/share/doc/libffi-3.0.5/LICENSE
/usr/share/doc/libffi-3.0.5/README


[root@vmx-dsm-038 ~]# yum install libffi-devel
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Setting up Install Process
No package libffi-devel available.
Error: Nothing to do

[root@vmx-dsm-038 ~]# yum upgrade libffi-devel
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Setting up Upgrade Process
No Match for argument: libffi-devel
No package libffi-devel available.
No Packages marked for Update
[root@vmx-dsm-038 ~]# yum upgrade libffi
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Setting up Upgrade Process
No Packages marked for Update

[root@vmx-dsm-038 ~]# locate libffi
/opt/Python-2.7.6/Modules/_ctypes/libffi
/opt/Python-2.7.6/Modules/_ctypes/libffi.diff
/opt/Python-2.7.6/Modules/_ctypes/libffi_arm_wince
/opt/Python-2.7.6/Modules/_ctypes/libffi_msvc
......
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/libffi/src/xtensa/.deps/sysv.Plo
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/libffi/testsuite/Makefile
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/closures.o
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/prep_cif.o
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/x86
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/x86/ffi.o
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/x86/ffi64.o
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/x86/sysv.o
/opt/Python-2.7.6/build/temp.linux-x86_64-2.7/opt/Python-2.7.6/Modules/_ctypes/libffi/src/x86/unix64.o
/usr/lib64/libffi.so.5
/usr/lib64/libffi.so.5.0.6
/usr/share/doc/libffi-3.0.5
/usr/share/doc/libffi-3.0.5/LICENSE
/usr/share/doc/libffi-3.0.5/README
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/checksum_data
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/checksum_type
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/from_repo
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/from_repo_revision
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/from_repo_timestamp
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/installed_by
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/reason
/var/lib/yum/yumdb/l/66af3a78b71c9ab35c98a0a9bcd1cb15d195d206-libffi-3.0.5-3.2.el6-x86_64/releasever

我终于找到了解决方案。感谢 NepCoder! 我从 https://pkgs.org/centos-6/centos-x86_64/libffi-devel-3.0.5-3.2.el6.x86_64.rpm.html 页手动下载 libffi-devel。然后使用 'rpm -ivh libffi-devel-3.0.5-3.2.el6.x86_64.rpm' 将其安装在我的虚拟机上。

之后一切正常。我猜我的 yum repo 可能有问题。