On macOS (Apple Silicon), I had trouble installing ansible-pylibssh because it could not find all the required sources.
Error#
# pip install ansible-pylibssh
Collecting ansible-pylibssh
Using cached ansible-pylibssh-1.2.0.post4.tar.gz (133 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: ansible-pylibssh
Building wheel for ansible-pylibssh (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for ansible-pylibssh (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
[1/1] Cythonizing /private/var/folders/s1/0057qklj5rs4bd2vysfdr6lh0000gn/T/.tmp-ansible-pylibssh-pep517-rzhivdqm/src/src/pylibsshext/_libssh_version.pyx
/private/var/folders/s1/0057qklj5rs4bd2vysfdr6lh0000gn/T/.tmp-ansible-pylibssh-pep517-rzhivdqm/src/src/pylibsshext/_libssh_version.c:1236:10: fatal error: 'libssh/libssh.h' file not found
#include "libssh/libssh.h"
^~~~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for ansible-pylibssh
Failed to build ansible-pylibssh
ERROR: Could not build wheels for ansible-pylibssh, which is required to install pyproject.toml-based projects
Fix#
Install libssh with homebrew.
brew install libssh
Run in your python venv pip install ansible-libssh
with the following compiler flags.
CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh" pip install ansible-pylibssh
Source: stackoverflow - Cannot install ansible-pylibssh on macOS