You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M1 Ventura系统pip安装easysnmp失败求助

解决M1 MacOS Ventura下pip安装easysnmp的报错问题

问题根源

报错里的NameError: name 'target_lib' is not defined是easysnmp官方setup.py的笔误——变量名应该是target_libs而非target_lib;同时M1 arm64架构下net-snmp的路径需要手动指定,否则会出现otool找不到文件的问题。

解决方案

1. 修复源码并本地安装

  • 克隆easysnmp仓库:
    git clone https://github.com/kamakazikamikaze/easysnmp.git
    cd easysnmp
    
  • 编辑setup.py文件,定位到第179行,将target_lib修改为target_libs
  • 执行本地安装:
    CFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" pip install .
    

2. 确保net-snmp适配arm64架构

如果之前用brew安装的net-snmp是x86版本,先卸载重装:

brew uninstall net-snmp
brew install net-snmp

M1 Mac下brew的默认安装路径是/opt/homebrew,上面的CFLAGS和LDFLAGS会指向正确的头文件和库文件路径,避免编译时找不到依赖的问题。

内容的提问来源于stack exchange,提问作者red wing

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 10:40:52