Page 1 of 1

Cannot install pysftp

Posted: Fri Dec 21, 2018 4:53 pm
by micksulley
Running Raspian, just done dist-upgrade so it is up to date.
According to https://pypi.org/project/pysftp/ I should be able to install pysftp with 'pip install pysftp', which worked on my desktop (Linux Mint) but does not work on my Pi. I have tried it with and without sudo. This is what I see

Code: Select all

[email protected]:~ $ pip install pysftp
Downloading/unpacking pysftp
  Downloading pysftp-0.2.9.tar.gz
  Running setup.py (path:/tmp/pip-build-91UTpS/pysftp/setup.py) egg_info for package pysftp
    
    no previously-included directories found matching 'docs/_build'
Downloading/unpacking paramiko>=1.17 (from pysftp)
  Downloading paramiko-2.4.2-py2.py3-none-any.whl (193kB): 193kB downloaded
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /usr/lib/python2.7/dist-packages (from paramiko>=1.17->pysftp)
Downloading/unpacking bcrypt>=3.1.3 (from paramiko>=1.17->pysftp)
  Downloading bcrypt-3.1.5.tar.gz (42kB): 42kB downloaded
  Running setup.py (path:/tmp/pip-build-91UTpS/bcrypt/setup.py) egg_info for package bcrypt
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    
    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>=1.17->pysftp)
  Downloading PyNaCl-1.3.0.tar.gz (3.4MB): 3.4MB downloaded
  Running setup.py (path:/tmp/pip-build-91UTpS/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: No such file or directory
     #include <ffi.h>
                     ^
    compilation terminated.
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-91UTpS/pynacl/setup.py", line 255, in <module>
        "Programming Language :: Python :: 3.7",
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 262, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 287, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 631, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 874, in best_match
        return self.obtain(req, installer)
      File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 886, in obtain
        return installer(requirement)
      File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 338, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 666, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 856, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1078, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1066, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'arm-linux-gnueabihf-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: No such file or directory

 #include <ffi.h>

                 ^

compilation terminated.

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip-build-91UTpS/pynacl/setup.py", line 255, in <module>

    "Programming Language :: Python :: 3.7",

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 262, in __init__

    self.fetch_build_eggs(attrs['setup_requires'])

  File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 287, in fetch_build_eggs

    replace_conflicting=True,

  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 631, in resolve

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

  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 874, in best_match

    return self.obtain(req, installer)

  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 886, in obtain

    return installer(requirement)

  File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 338, in fetch_build_egg

    return cmd.easy_install(req)

  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 636, in easy_install

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

  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 666, in install_item

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

  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 856, in install_eggs

    return self.build_and_install(setup_script, setup_base)

  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1078, in build_and_install

    self.run_setup(setup_script, setup_base, args)

  File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1066, in run_setup

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

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

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-91UTpS/pynacl
Storing debug log for failure in /home/control/.pip/pip.log
[email protected]:~ $ 
Any suggestions how to fix it?

Re: Cannot install pysftp

Posted: Sat Dec 22, 2018 12:16 am
by MrYsLab
I just installed for python2 using:

Code: Select all

sudo pip install pysftp
Also, for python3:

Code: Select all

sudo pip3 install pysftp
And finally for a python3 virtual environment:

Code: Select all

pip install pysftp
All 3 installs were successful.

Looking at your output, it states "No package 'libffi' found". You can check to see if you have libffi installed. To check to see if libffi is installed type:

Code: Select all

dpkg-query -l | grep libffi
When I run this, I see libffi-dev and libffi both are installed.

If you do not see either of these, use sudo apt-get install FILENAME to install the appropriate package.

Re: Cannot install pysftp

Posted: Sat Dec 22, 2018 9:05 am
by micksulley
Thanks for the reply. I had libff6 but not libffi-dev, so I install that and tried again. It failed again,,

Code: Select all

[email protected]:~ $ pip install pysftp
Downloading/unpacking pysftp
  Downloading pysftp-0.2.9.tar.gz
  Running setup.py (path:/tmp/pip-build-BdmCHc/pysftp/setup.py) egg_info for package pysftp
    
    no previously-included directories found matching 'docs/_build'
Downloading/unpacking paramiko>=1.17 (from pysftp)
  Downloading paramiko-2.4.2-py2.py3-none-any.whl (193kB): 193kB downloaded
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /usr/lib/python2.7/dist-packages (from paramiko>=1.17->pysftp)
Downloading/unpacking bcrypt>=3.1.3 (from paramiko>=1.17->pysftp)
  Downloading bcrypt-3.1.5.tar.gz (42kB): 42kB downloaded
  Running setup.py (path:/tmp/pip-build-BdmCHc/bcrypt/setup.py) egg_info for package bcrypt
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    
    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>=1.17->pysftp)
  Downloading PyNaCl-1.3.0.tar.gz (3.4MB): 3.4MB downloaded
  Running setup.py (path:/tmp/pip-build-BdmCHc/pynacl/setup.py) egg_info for package pynacl
    
    Installed /tmp/pip-build-BdmCHc/pynacl/cffi-1.11.5-py2.7-linux-armv7l.egg
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip-build-BdmCHc/pynacl/setup.py", line 255, in <module>
        "Programming Language :: Python :: 3.7",
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 266, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 301, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
        ['__name__'])
    ImportError: No module named setuptools_ext
    Complete output from command python setup.py egg_info:
    

Installed /tmp/pip-build-BdmCHc/pynacl/cffi-1.11.5-py2.7-linux-armv7l.egg

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip-build-BdmCHc/pynacl/setup.py", line 255, in <module>

    "Programming Language :: Python :: 3.7",

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 266, in __init__

    _Distribution.__init__(self,attrs)

  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__

    self.finalize_options()

  File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 301, in finalize_options

    ep.load()(self, ep.name, value)

  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load

    ['__name__'])

ImportError: No module named setuptools_ext

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-BdmCHc/pynacl
Storing debug log for failure in /home/control/.pip/pip.log
[email protected]:
so I tried to install setuptool_ext, both with apt-get and with pip

Code: Select all

[email protected]:~ $ sudo apt-get install setuptools_ext
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package setuptools_ext
[email protected]:~ $ pip install setuptools_ext
Downloading/unpacking setuptools-ext
  Could not find any downloads that satisfy the requirement setuptools-ext
Cleaning up...
No distributions at all found for setuptools-ext
Storing debug log for failure in /home/control/.pip/pip.log
[email protected]:~ $ 
I did search for answers to this, found a suggestion to install python-setuptools but that is already installed

Any idea?

Re: Cannot install pysftp

Posted: Sat Dec 22, 2018 8:35 pm
by MrYsLab
I am not sure what the problem is within your environment. I just reinstalled raspbian 2018-11-13, performed a sudo apt-get update and upgrade.
I then installed pysftp for python3 (it takes forever to install for python 2). I do not get any errors. Here is my console output:

Code: Select all

[email protected]:~ $ sudo pip3 install pysftp
Collecting pysftp
  Downloading https://www.piwheels.org/simple/pysftp/pysftp-0.2.9-py3-none-any.whl
Collecting paramiko>=1.17 (from pysftp)
  Downloading https://files.pythonhosted.org/packages/cf/ae/94e70d49044ccc234bfdba20114fa947d7ba6eb68a2e452d89b920e62227/paramiko-2.4.2-py2.py3-none-any.whl (193kB)
    100% |████████████████████████████████| 194kB 732kB/s 
Requirement already satisfied: pyasn1>=0.1.7 in /usr/lib/python3/dist-packages (from paramiko>=1.17->pysftp)
Collecting bcrypt>=3.1.3 (from paramiko>=1.17->pysftp)
  Downloading https://www.piwheels.org/simple/bcrypt/bcrypt-3.1.5-cp35-cp35m-linux_armv7l.whl (54kB)
    100% |████████████████████████████████| 61kB 246kB/s 
Collecting pynacl>=1.0.1 (from paramiko>=1.17->pysftp)
  Downloading https://www.piwheels.org/simple/pynacl/PyNaCl-1.3.0-cp35-cp35m-linux_armv7l.whl (543kB)
    100% |████████████████████████████████| 552kB 243kB/s 
Requirement already satisfied: cryptography>=1.5 in /usr/lib/python3/dist-packages (from paramiko>=1.17->pysftp)
Collecting cffi>=1.1 (from bcrypt>=3.1.3->paramiko>=1.17->pysftp)
  Downloading https://www.piwheels.org/simple/cffi/cffi-1.11.5-cp35-cp35m-linux_armv7l.whl (304kB)
    100% |████████████████████████████████| 307kB 372kB/s 
Requirement already satisfied: six>=1.4.1 in /usr/lib/python3/dist-packages (from bcrypt>=3.1.3->paramiko>=1.17->pysftp)
Collecting pycparser (from cffi>=1.1->bcrypt>=3.1.3->paramiko>=1.17->pysftp)
  Downloading https://www.piwheels.org/simple/pycparser/pycparser-2.19-py2.py3-none-any.whl (111kB)
    100% |████████████████████████████████| 112kB 372kB/s 
Installing collected packages: pycparser, cffi, bcrypt, pynacl, paramiko, pysftp
Successfully installed bcrypt-3.1.5 cffi-1.11.5 paramiko-2.4.2 pycparser-2.19 pynacl-1.3.0 pysftp-0.2.9

Re: Cannot install pysftp

Posted: Sun Dec 23, 2018 4:55 pm
by MrYsLab
A thought - are you using the" Raspbian Stretch with desktop and recommended software" version or one of the other versions? I tested with the recommended version.

Re: Cannot install pysftp

Posted: Sun Dec 23, 2018 5:56 pm
by micksulley
No it is Jessie lite, runs headless so no desktop stuff.

How can I upgrade to Stretch? I thought that
sudo apt-get update
sudo apt-get dist-upgrade
would do it, but just tried that and it is still Jessie

Re: Cannot install pysftp

Posted: Sun Dec 23, 2018 7:30 pm
by MrYsLab
I was never able to successfully upgrade from Jessie to Stretch. There are some articles on how to try to do this and here is an example https://www.datenreise.de/en/raspberry- ... o-stretch/.

I have no idea whether or not these instructions are correct, so use at your own risk.

I have never used any of the lite versions of Raspbian, so I don't know if the lite versions have stripped out some key components that the pysftp distribution requires for a successful installation.

I too run headless, but on occasion need the GUI interface, so I boot into the desktop and access the GUI with xrdp when I need it. I never checked to see if this affects CPU utlization compared with botting into the CLI.

Unless you are very tight on SD card space, my suggestion would be to install the latest full version of Raspbian to get your project going as quickly as possible.

Re: Cannot install pysftp

Posted: Sun Dec 23, 2018 9:12 pm
by MrYsLab
Yet some more info for you. I just installed stretch-lite, and then installed pip 3 using:

Code: Select all

sudo apt-get install python3-pip
.

I then did an install of pysftp and it installed without error using:

Code: Select all

sudo pip3 install pysftp

Re: Cannot install pysftp

Posted: Sun Dec 23, 2018 10:26 pm
by micksulley
Thanks for your help. I think I will do a fresh install from scratch and start again.

Re: Cannot install pysftp - Fixed!

Posted: Fri Feb 08, 2019 11:33 am
by micksulley
In case anyone else has this problem this is what I did to get it workng
Fresh install of Raspbian Stretch - still didn't work, so after much research, trial and error -

Code: Select all

sudo apt-get install python-pip
pip install --user -U setuptools
sudo pip install --upgrade pip
sudo apt-get install libffi-dev
sudo pip install pysftp
Not sure if all of the steps are necessary, but it worked!