ubuntu14.04.5安装paramiko模块pip install paramiko出现一堆问题的解决过程

为什么80%的码农都做不了架构师?>>>   hot3.png

根据paramiko官网的指示,可以使用pip安装paramiko模块默认安装最新的稳定版本的paramiko
使用pip安装paramiko

sudo pip3 install paramiko

出现一堆错误信息:

liuxin@sunshine-virtual-machine:~/work/python/python/socket/socketserver/ftp_client$ sudo pip3 install paramiko
[sudo] password for liuxin: 
对不起,请重试。
[sudo] password for liuxin: 
对不起,请重试。
[sudo] password for liuxin: 
Downloading/unpacking paramiko
  Downloading paramiko-2.4.0-py2.py3-none-any.whl (192kB): 192kB downloaded
Downloading/unpacking bcrypt>=3.1.3 (from paramiko)
  Downloading bcrypt-3.1.4.tar.gz (42kB): 42kB downloaded
  Running setup.py (path:/tmp/pip_build_root/bcrypt/setup.py) egg_info for package bcrypt
    
    warning: no previously-included files found matching 'requirements.txt'
    warning: no previously-included files found matching 'tasks.py'
    warning: no previously-included files found matching '.travis.yml'
    warning: no previously-included files found matching 'wheel-scripts'
    warning: no previously-included files found matching 'Jenkinsfile'
    warning: no previously-included files found matching '.jenkins'
    warning: no previously-included files matching '*' found under directory '.jenkins'
    warning: no previously-included files matching '*' found under directory 'wheel-scripts'
    no previously-included directories found matching '.travis'
Downloading/unpacking pynacl>=1.0.1 (from paramiko)
  Downloading PyNaCl-1.2.1.tar.gz (3.3MB): 3.3MB downloaded
  Running setup.py (path:/tmp/pip_build_root/pynacl/setup.py) egg_info for package pynacl
    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: fatal error: ffi.h: 没有那个文件或目录
     #include 
                     ^
    compilation terminated.
    Traceback (most recent call last):
      File "/usr/lib/python3.4/distutils/unixccompiler.py", line 116, in _compile
        extra_postargs)
      File "/usr/lib/python3.4/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/lib/python3.4/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/lib/python3.4/distutils/spawn.py", line 162, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'i686-linux-gnu-gcc' failed with exit status 1
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 185, in run
        cmd = self.call_command('install_lib', warn_dir=0)
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 171, in call_command
        self.run_command(cmdname)
      File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 21, in run
        self.build()
      File "/usr/lib/python3.4/distutils/command/install_lib.py", line 109, in build
        self.run_command('build_ext')
      File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 49, in run
        _build_ext.run(self)
      File "/usr/lib/python3.4/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/usr/lib/python3.4/distutils/command/build_ext.py", line 448, in build_extensions
        self.build_extension(ext)
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 178, in build_extension
        _build_ext.build_extension(self,ext)
      File "/usr/lib/python3.4/distutils/command/build_ext.py", line 503, in build_extension
        depends=ext.depends)
      File "/usr/lib/python3.4/distutils/ccompiler.py", line 574, in compile
        self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
      File "/usr/lib/python3.4/distutils/unixccompiler.py", line 118, in _compile
        raise CompileError(msg)
    distutils.errors.CompileError: command 'i686-linux-gnu-gcc' failed with exit status 1
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1025, in run_setup
        run_setup(setup_script, args)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 50, in run_setup
        lambda: execfile(
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 100, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 52, in 
        {'__file__':setup_script, '__name__':'__main__'}
      File "/usr/lib/python3/dist-packages/setuptools/compat.py", line 78, in execfile
        exec(compile(source, fn, 'exec'), globs, locs)
      File "setup.py", line 236, in 
        cmdclass={
      File "/usr/lib/python3.4/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'i686-linux-gnu-gcc' failed with exit status 1
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "", line 17, in 
      File "/tmp/pip_build_root/pynacl/setup.py", line 251, in 
        "Programming Language :: Python :: 3.6",
      File "/usr/lib/python3.4/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 239, in __init__
        self.fetch_build_eggs(attrs.pop('setup_requires'))
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 264, in fetch_build_eggs
        replace_conflicting=True
      File "/usr/lib/python3/dist-packages/pkg_resources.py", line 620, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources.py", line 858, in best_match
        return self.obtain(req, installer) # try and download/install
      File "/usr/lib/python3/dist-packages/pkg_resources.py", line 870, in obtain
        return installer(requirement)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 314, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 616, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 646, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 834, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1040, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1028, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'i686-linux-gnu-gcc' failed with exit status 1
    Complete output from command python setup.py egg_info:
    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: fatal error: ffi.h: 没有那个文件或目录

 #include 

                 ^

compilation terminated.

Traceback (most recent call last):

  File "/usr/lib/python3.4/distutils/unixccompiler.py", line 116, in _compile

    extra_postargs)

  File "/usr/lib/python3.4/distutils/ccompiler.py", line 909, in spawn

    spawn(cmd, dry_run=self.dry_run)

  File "/usr/lib/python3.4/distutils/spawn.py", line 36, in spawn

    _spawn_posix(cmd, search_path, dry_run=dry_run)

  File "/usr/lib/python3.4/distutils/spawn.py", line 162, in _spawn_posix

    % (cmd, exit_status))

distutils.errors.DistutilsExecError: command 'i686-linux-gnu-gcc' failed with exit status 1



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/usr/lib/python3.4/distutils/core.py", line 148, in setup

    dist.run_commands()

  File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands

    self.run_command(cmd)

  File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command

    cmd_obj.run()

  File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 185, in run

    cmd = self.call_command('install_lib', warn_dir=0)

  File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 171, in call_command

    self.run_command(cmdname)

  File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command

    self.distribution.run_command(command)

  File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command

    cmd_obj.run()

  File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 21, in run

    self.build()

  File "/usr/lib/python3.4/distutils/command/install_lib.py", line 109, in build

    self.run_command('build_ext')

  File "/usr/lib/python3.4/distutils/cmd.py", line 313, in run_command

    self.distribution.run_command(command)

  File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command

    cmd_obj.run()

  File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 49, in run

    _build_ext.run(self)

  File "/usr/lib/python3.4/distutils/command/build_ext.py", line 339, in run

    self.build_extensions()

  File "/usr/lib/python3.4/distutils/command/build_ext.py", line 448, in build_extensions

    self.build_extension(ext)

  File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 178, in build_extension

    _build_ext.build_extension(self,ext)

  File "/usr/lib/python3.4/distutils/command/build_ext.py", line 503, in build_extension

    depends=ext.depends)

  File "/usr/lib/python3.4/distutils/ccompiler.py", line 574, in compile

    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)

  File "/usr/lib/python3.4/distutils/unixccompiler.py", line 118, in _compile

    raise CompileError(msg)

distutils.errors.CompileError: command 'i686-linux-gnu-gcc' failed with exit status 1



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1025, in run_setup

    run_setup(setup_script, args)

  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 50, in run_setup

    lambda: execfile(

  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 100, in run

    return func()

  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 52, in 

    {'__file__':setup_script, '__name__':'__main__'}

  File "/usr/lib/python3/dist-packages/setuptools/compat.py", line 78, in execfile

    exec(compile(source, fn, 'exec'), globs, locs)

  File "setup.py", line 236, in 

    cmdclass={

  File "/usr/lib/python3.4/distutils/core.py", line 163, in setup

    raise SystemExit("error: " + str(msg))

SystemExit: error: command 'i686-linux-gnu-gcc' failed with exit status 1



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "", line 17, in 

  File "/tmp/pip_build_root/pynacl/setup.py", line 251, in 

    "Programming Language :: Python :: 3.6",

  File "/usr/lib/python3.4/distutils/core.py", line 108, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 239, in __init__

    self.fetch_build_eggs(attrs.pop('setup_requires'))

  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 264, in fetch_build_eggs

    replace_conflicting=True

  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 620, in resolve

    dist = best[req.key] = env.best_match(req, ws, installer)

  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 858, in best_match

    return self.obtain(req, installer) # try and download/install

  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 870, in obtain

    return installer(requirement)

  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 314, in fetch_build_egg

    return cmd.easy_install(req)

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 616, in easy_install

    return self.install_item(spec, dist.location, tmpdir, deps)

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 646, in install_item

    dists = self.install_eggs(spec, download, tmpdir)

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 834, in install_eggs

    return self.build_and_install(setup_script, setup_base)

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1040, in build_and_install

    self.run_setup(setup_script, setup_base, args)

  File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1028, in run_setup

    raise DistutilsError("Setup script exited with %s" % (v.args[0],))

distutils.errors.DistutilsError: Setup script exited with error: command 'i686-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/pynacl
Storing debug log for failure in /home/liuxin/.pip/pip.log

 

查看错误日志时发现一条信息:

No package 'libffi' found

所以使用下面安装libffi:

sudo apt-get install libffi-dev

再次使用pip3安装paramiko模块又提示如下错误:

error in cryptography setup command: Invalid environment marker: python_version < '3'

别灰心,出现别的错误说明有进展
上网搜了一下这个错误找到一个解决方案:https://github.com/ansible/ansible/issues/31741
ubuntu14.04.5安装paramiko模块pip install paramiko出现一堆问题的解决过程_第1张图片
看到没?它也在安装libffi,至少说明我们的方向没有错, 按照大神的提示执行一下指令:

sudo pip3 install --upgrade setuptools
sudo apt-get install libffi-dev libssl-dev

再次安装paramiko

sudo pip3 install paramiko

安装成功,打开python3解释器测试模块:

Successfully installed paramiko pyasn1 bcrypt cryptography pynacl cffi idna asn1crypto pycparser
Cleaning up...
liuxin@sunshine-virtual-machine:~/work/python/python/socket/socketserver/ftp_client$ python3
Python 3.4.3 (default, Nov 28 2017, 16:40:41) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
>>> 

ok, 搞定

 

总结:
    在使用pip3安装paramiko模块执行以下指令:

sudo pip3 install --upgrade setuptools
sudo apt-get install libffi-dev libssl-dev
sudo pip3 install paramiko

 

转载于:https://my.oschina.net/enfp/blog/1607243

你可能感兴趣的:(ubuntu14.04.5安装paramiko模块pip install paramiko出现一堆问题的解决过程)