Skip to main content
  1. Posts/

Fixing install ansible-pylibssh on macOS (Apple Silicon)

·195 words·1 min·
Kb Macos Ansible Fix
Maximilian Thoma
Author
Maximilian Thoma
network engineer
Table of Contents

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

Related

Netdevops python libraries toolbox
·1720 words·9 mins
Netdevops Blog Python Apiflask Flask Loguru Ciscoconfparse Dynaconf Pymongo Rq Netmiko Paramiko Ansible Pandas Ntc_templates Textfsm Requests
Use Ansible Tower API
·349 words·2 mins
Netdevops Blog Python Ansible Tower Api
Interaction with REST API <-> Ansible playbook
·473 words·3 mins
Netdevops Blog Ansible Api