Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install error in package ssh2-python #367

Open
FengJiDetecon opened this issue Dec 5, 2022 · 4 comments
Open

install error in package ssh2-python #367

FengJiDetecon opened this issue Dec 5, 2022 · 4 comments

Comments

@FengJiDetecon
Copy link

Describe the bug
the problem is caused first by
from ssh2.error_codes import LIBSSH2_ERROR_EAGAI
which tries to load error_codes.cpython-37m-darwin.so but fails
the reason is that
'/private/var/folders/zb/t0r1t7451tx4vfhc9jbk2rzr0000gn/T/pip-install-vik15j8x/ssh2-python_fc1f843181664c9aa95e798b0c981b59/build_dir/src/libssh2.1.dylib' (no such file)

To Reproduce

Steps to reproduce the behavior:

  1. pip3 install parallel-ssh

Expected behavior
installed

Actual behaviour
error msg

Screenshots
Bildschirm­foto 2022-12-05 um 16 02 26

Additional information
on Mac os
cmake and gcc installed
cmake version 3.24.2
gcc 12.2.0

@plamendelchev
Copy link

Hi, I had the same problem. I managed to solve it by installing libssh2 with brew and setting up LDFLAGS and CPPFLAGS:

$ brew install libssh2

$ grep libssh2 ~/.zshrc
export LDFLAGS="-L${HOME}/brew/opt/libssh2/lib"
export CPPFLAGS="-I${HOME}/brew/opt/libssh2/include"

$ pip3 cache purge

$ pip3 install parallel-ssh
...
Successfully installed gevent-22.10.2 greenlet-2.0.1 parallel-ssh-2.12.0 ssh-python-1.0.0 ssh2-python-1.0.0 zope.event-4.6 zope.interface-5.5.2

$ cat test.py
from pssh.clients import SSHClient

client = SSHClient(host='github.com', user='git', port=22, pkey='~/.ssh/github')
host_out = client.run_command('hostname')
for line in host_out.stdout:
    print(line)
for line in host_out.stderr:
    print(line)

$ python3 test.py
Invalid command: 'hostname'
  You appear to be using ssh to clone a git:// URL.
  Make sure your core.gitProxy config option and the
  GIT_PROXY_COMMAND environment variable are NOT set.

@jandvorak-sol60279
Copy link

jandvorak-sol60279 commented Jan 3, 2023

Hi, I had the same problem. I managed to solve it by installing libssh2 with brew and setting up LDFLAGS and CPPFLAGS:

$ brew install libssh2

$ grep libssh2 ~/.zshrc
export LDFLAGS="-L${HOME}/brew/opt/libssh2/lib"
export CPPFLAGS="-I${HOME}/brew/opt/libssh2/include"

$ pip3 cache purge

$ pip3 install parallel-ssh
...
Successfully installed gevent-22.10.2 greenlet-2.0.1 parallel-ssh-2.12.0 ssh-python-1.0.0 ssh2-python-1.0.0 zope.event-4.6 zope.interface-5.5.2

$ cat test.py
from pssh.clients import SSHClient

client = SSHClient(host='github.com', user='git', port=22, pkey='~/.ssh/github')
host_out = client.run_command('hostname')
for line in host_out.stdout:
    print(line)
for line in host_out.stderr:
    print(line)

$ python3 test.py
Invalid command: 'hostname'
  You appear to be using ssh to clone a git:// URL.
  Make sure your core.gitProxy config option and the
  GIT_PROXY_COMMAND environment variable are NOT set.

had the same issue and with some modification went to success

need to change flags path

export LDFLAGS="-L$(dirname $(which brew))/../opt/libssh2/lib"
export CPPFLAGS="-I$(dirname $(which brew))/../opt/libssh2/include"

install cmake (obviously)

brew install cmake

after that i got another (openssl) error

CMake Error at /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
        Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
        system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
        OPENSSL_INCLUDE_DIR)

even tho openssl was in some obscure version, i did install it thru brew

brew install openssl

crate links

brew link --force openssl

and hallelujah ... installing parallel-ssh went finally ok and working (using fresh venv)

@FengJi2021
Copy link

both not working for me? any trouble shooting suggestion? i think this package using cpython to get openssl and problem shall be compiler lib link.

@rvencu
Copy link

rvencu commented Oct 24, 2024

Same, it happens to me on macOS sequoia with M3. For python 3.11 or older it breaks at

[  7%] Building C object src/CMakeFiles/libssh2.dir/crypt.c.o
      /private/var/folders/my/hvn4fhm9119c1kpd2zgq252w0000gn/T/pip-install-p2qpfboq/ssh2-python_7aa2cb2d0fef475e9bfb91b81e3380fc/libssh2/libssh2/src/crypt.c:62:5: error: incompatible function pointer types initializing 'int (*)(LIBSSH2_SESSION *, unsigned char *, size_t, void **)' (aka 'int (*)(struct _LIBSSH2_SESSION *, unsigned char *, unsigned long, void **)') with an expression of type 'int (LIBSSH2_SESSION *, unsigned char *, void **)' (aka 'int (struct _LIBSSH2_SESSION *, unsigned char *, void **)') [-Wincompatible-function-pointer-types]
         62 |     crypt_none_crypt,
            |     ^~~~~~~~~~~~~~~~
      1 error generated.
      make[2]: *** [src/CMakeFiles/libssh2.dir/crypt.c.o] Error 1
      make[1]: *** [src/CMakeFiles/libssh2.dir/all] Error 2
      make: *** [all] Error 2
      Traceback (most recent call last):
        File "/Users/richard/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/richard/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/richard/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/my/hvn4fhm9119c1kpd2zgq252w0000gn/T/pip-build-env-1rym97ox/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 373, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/my/hvn4fhm9119c1kpd2zgq252w0000gn/T/pip-build-env-1rym97ox/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 516, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/my/hvn4fhm9119c1kpd2zgq252w0000gn/T/pip-build-env-1rym97ox/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 32, in <module>
        File "/private/var/folders/my/hvn4fhm9119c1kpd2zgq252w0000gn/T/pip-install-p2qpfboq/ssh2-python_7aa2cb2d0fef475e9bfb91b81e3380fc/_setup_libssh2.py", line 39, in build_ssh2
          check_call('cmake --build . --config Release', shell=True, env=os.environ)
        File "/opt/homebrew/Cellar/[email protected]/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command 'cmake --build . --config Release' returned non-zero exit status 2.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Python3.12 has more issues, maybe the package is not compatible yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants