【问题标题】:An issue with installation of ansible-pylibssh on Apple Silicon M2在 Apple Silicon M2 上安装 ansible-pylibssh 的问题
【发布时间】:2023-02-16 23:00:01
【问题描述】:

我在安装 ansible-pylibssh 时遇到问题。 安装过程中

pip3 install --user ansible-pylibssh 

我有

ld: library not found for -lssh
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit code 1

有人可以解释如何克服这个问题吗?

我已经做了软链接

% cd /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
% sudo ln -s /opt/homebrew/Cellar/libssh/0.10.4/include/libssh/ libssh

【问题讨论】:

  • 已经安装了 clang。 nec@192 Documents % clang -v Apple clang version 14.0.0 (clang-1400.0.29.202) 目标:arm64-apple-darwin22.2.0 线程模型:posix 安装目录:/Library/Developer/CommandLineTools/usr/bin

标签: ansible


【解决方案1】:

安装 libssh:

brew install libssh

使用 python 虚拟环境:

python3 -m venv .venv
source .venv/bin/activate

安装tox构建工具:

pip install 'tox >= 3.19.0'

根据ansible-pylibssh docs,在基于 ARM 的 Mac 上从源代码构建:

#git clone https://github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
# or, if you use SSH:
git clone ssh://git@github.com/ansible/pylibssh.git ~/src/github/ansible/pylibssh
cd ~/src/github/ansible/pylibssh

Use libraries installed by brew with clang:

export CFLAGS="-I $(brew --prefix)/include -I ext -L $(brew --prefix)/lib -lssh"

构建 ansible-pylibssh:

tox -e build-dists

安装内置的ansible-pylibssh wheel:

pip install ~/src/github/ansible/pylibssh/dist/ansible_pylibssh*.whl

导致此答案的其他资源:

如果您不喜欢使用虚拟环境,这可能会起作用:将pip命令替换为python3

【讨论】:

    猜你喜欢
    • 2021-05-15
    • 2021-05-08
    • 2021-05-24
    • 2022-01-22
    • 2021-03-11
    • 2021-04-21
    • 2022-01-06
    • 1970-01-01
    相关资源
    最近更新 更多