Mac OS X: 无法通过 pip 安装 easysnmp
Mac OS X: unable to install easysnmp via pip
我正在尝试通过 pip 在 Mac OS 上安装 python easysnmp
包,但出现以下问题
➜ ~ pip install easysnmp
Collecting easysnmp
Using cached https://files.pythonhosted.org/packages/e0/6f/2fd5c9113a488c81aa95f9006744c6998878a80135010f87506638ba6d5c/easysnmp-0.2.5.tar.gz
Installing collected packages: easysnmp
Running setup.py install for easysnmp ... error
ERROR: Complete output from command /Users/luk/.pyenv/versions/3.6.5/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-install-u6hwnvnm/easysnmp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-record-wvtda6_o/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.6
creating build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/compat.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/variables.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/session.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/__init__.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/easy.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/utils.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/exceptions.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/helpers.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
running build_ext
building 'easysnmp.interface' extension
creating build/temp.macosx-10.14-x86_64-3.6
creating build/temp.macosx-10.14-x86_64-3.6/easysnmp
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/usr/local/opt/zlib/include -I/Users/vyah/.pyenv/versions/3.6.5/include/python3.6m -c easysnmp/interface.c -o build/temp.macosx-10.14-x86_64-3.6/easysnmp/interface.o -Wno-unused-function
In file included from easysnmp/interface.c:46:
easysnmp/simple_bitarray.h:116:29: warning: variable 'nbytes' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
for (i = nbits; i > (nbits - remaining_bits); i--)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/simple_bitarray.h:122:27: note: uninitialized use occurs here
memset(&ba[1], 0, nbytes);
^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:76:33: note: expanded from macro 'memset'
__builtin___memset_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^~~~~~~~~~~
easysnmp/simple_bitarray.h:116:29: note: remove the condition if it is always true
for (i = nbits; i > (nbits - remaining_bits); i--)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/simple_bitarray.h:98:22: note: initialize the variable 'nbytes' to silence this warning
size_t nbytes;
^
= 0
easysnmp/interface.c:454:25: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
if (len > buf_len)
~~~ ^ ~~~~~~~
easysnmp/interface.c:1220:48: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]
else if (last_errindex > (*response)->errindex)
~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
easysnmp/interface.c:2379:55: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare]
if (snmp_version == 1 && DEFAULT_NUM_BAD_OIDS < varlist_len)
~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
easysnmp/interface.c:2853:44: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
if ((vars->name_length < oid_arr_len[varlist_ind]) ||
~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/interface.c:3584:48: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
if ((vars->name_length < oid_arr_len[varlist_ind]) ||
~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/interface.c:3889:28: warning: comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and 'unsigned long' [-Wsign-compare]
if (tmplen >= sizeof(tmp_val_str))
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
7 warnings generated.
clang -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/luk/.pyenv/versions/3.6.5/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/luk/.pyenv/versions/3.6.5/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/zlib/lib -I/usr/local/opt/zlib/include build/temp.macosx-10.14-x86_64-3.6/easysnmp/interface.o -lnetsnmp -lcrypto.35 -o build/lib.macosx-10.14-x86_64-3.6/easysnmp/interface.cpython-36m-darwin.so
ld: library not found for -lcrypto.35
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Command "/Users/luk/.pyenv/versions/3.6.5/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-install-u6hwnvnm/easysnmp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-record-wvtda6_o/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-install-u6hwnvnm/easysnmp/
我使用 pyenv
、python 3.6.5
、pip 19.1.1
和 Mac OS Mojave 10.14.3
。此外,我已经安装了 net-snmp 5.8
和 gcc 9.1
依赖项:
➜ ~ python -V
Python 3.6.5
➜ ~ pip -V
pip 19.1.1 from /3.6.5/lib/python3.6/site-packages/pip (python 3.6)
➜ ~ pyenv -v
pyenv 1.2.9
➜ ~ brew info net-snmp
net-snmp: stable 5.8 (bottled) [keg-only]
Implements SNMP v1, v2c, and v3, using IPv4 and IPv6
➜ ~ brew info gcc
gcc: stable 9.1.0 (bottled), HEAD
在通过 apt-get install -y libsnmp-dev snmp libyaml-dev gcc
安装依赖项后,我在 Ubuntu 上成功安装了 easysnmp
,但尚未找到 Mac OS 的替代方案.如果有任何帮助,我将不胜感激!
我终于找到了解决办法,好像我的 /usr/local/opt/openssl/lib
文件夹不包含 libcrypto.35.dylib
库。幸运的是 libcrypto.35.dylib
位于 /usr/lib
文件夹中,因此将 libcrypto.35.dylib
库放入 /usr/local/opt/openssl/lib
文件夹中的解决方案非常明显。
结果我通过
创建了一个符号link
➜ ln -s /usr/lib/libcrypto.35.dylib /usr/local/opt/openssl/lib/libcrypto.35.dylib
然后我才能够通过 pip
安装 easysnmp
➜ pip install easysnmp
Collecting easysnmp
Using cached https://files.pythonhosted.org/packages/e0/6f/2fd5c9113a488c81aa95f9006744c6998878a80135010f87506638ba6d5c/easysnmp-0.2.5.tar.gz
Installing collected packages: easysnmp
Running setup.py install for easysnmp ... done
Successfully installed easysnmp-0.2.5
我正在尝试通过 pip 在 Mac OS 上安装 python easysnmp
包,但出现以下问题
➜ ~ pip install easysnmp
Collecting easysnmp
Using cached https://files.pythonhosted.org/packages/e0/6f/2fd5c9113a488c81aa95f9006744c6998878a80135010f87506638ba6d5c/easysnmp-0.2.5.tar.gz
Installing collected packages: easysnmp
Running setup.py install for easysnmp ... error
ERROR: Complete output from command /Users/luk/.pyenv/versions/3.6.5/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-install-u6hwnvnm/easysnmp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-record-wvtda6_o/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.6
creating build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/compat.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/variables.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/session.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/__init__.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/easy.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/utils.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/exceptions.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
copying easysnmp/helpers.py -> build/lib.macosx-10.14-x86_64-3.6/easysnmp
running build_ext
building 'easysnmp.interface' extension
creating build/temp.macosx-10.14-x86_64-3.6
creating build/temp.macosx-10.14-x86_64-3.6/easysnmp
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/usr/local/opt/zlib/include -I/Users/vyah/.pyenv/versions/3.6.5/include/python3.6m -c easysnmp/interface.c -o build/temp.macosx-10.14-x86_64-3.6/easysnmp/interface.o -Wno-unused-function
In file included from easysnmp/interface.c:46:
easysnmp/simple_bitarray.h:116:29: warning: variable 'nbytes' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
for (i = nbits; i > (nbits - remaining_bits); i--)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/simple_bitarray.h:122:27: note: uninitialized use occurs here
memset(&ba[1], 0, nbytes);
^~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:76:33: note: expanded from macro 'memset'
__builtin___memset_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^~~~~~~~~~~
easysnmp/simple_bitarray.h:116:29: note: remove the condition if it is always true
for (i = nbits; i > (nbits - remaining_bits); i--)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/simple_bitarray.h:98:22: note: initialize the variable 'nbytes' to silence this warning
size_t nbytes;
^
= 0
easysnmp/interface.c:454:25: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
if (len > buf_len)
~~~ ^ ~~~~~~~
easysnmp/interface.c:1220:48: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]
else if (last_errindex > (*response)->errindex)
~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
easysnmp/interface.c:2379:55: warning: comparison of integers of different signs: 'unsigned long' and 'int' [-Wsign-compare]
if (snmp_version == 1 && DEFAULT_NUM_BAD_OIDS < varlist_len)
~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
easysnmp/interface.c:2853:44: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
if ((vars->name_length < oid_arr_len[varlist_ind]) ||
~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/interface.c:3584:48: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
if ((vars->name_length < oid_arr_len[varlist_ind]) ||
~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
easysnmp/interface.c:3889:28: warning: comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and 'unsigned long' [-Wsign-compare]
if (tmplen >= sizeof(tmp_val_str))
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
7 warnings generated.
clang -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/luk/.pyenv/versions/3.6.5/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/Users/luk/.pyenv/versions/3.6.5/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/zlib/lib -I/usr/local/opt/zlib/include build/temp.macosx-10.14-x86_64-3.6/easysnmp/interface.o -lnetsnmp -lcrypto.35 -o build/lib.macosx-10.14-x86_64-3.6/easysnmp/interface.cpython-36m-darwin.so
ld: library not found for -lcrypto.35
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Command "/Users/luk/.pyenv/versions/3.6.5/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-install-u6hwnvnm/easysnmp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-record-wvtda6_o/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/hz/xgmhyb9x6c907lm81h82g1tm3znyk3/T/pip-install-u6hwnvnm/easysnmp/
我使用 pyenv
、python 3.6.5
、pip 19.1.1
和 Mac OS Mojave 10.14.3
。此外,我已经安装了 net-snmp 5.8
和 gcc 9.1
依赖项:
➜ ~ python -V
Python 3.6.5
➜ ~ pip -V
pip 19.1.1 from /3.6.5/lib/python3.6/site-packages/pip (python 3.6)
➜ ~ pyenv -v
pyenv 1.2.9
➜ ~ brew info net-snmp
net-snmp: stable 5.8 (bottled) [keg-only]
Implements SNMP v1, v2c, and v3, using IPv4 and IPv6
➜ ~ brew info gcc
gcc: stable 9.1.0 (bottled), HEAD
在通过 apt-get install -y libsnmp-dev snmp libyaml-dev gcc
安装依赖项后,我在 Ubuntu 上成功安装了 easysnmp
,但尚未找到 Mac OS 的替代方案.如果有任何帮助,我将不胜感激!
我终于找到了解决办法,好像我的 /usr/local/opt/openssl/lib
文件夹不包含 libcrypto.35.dylib
库。幸运的是 libcrypto.35.dylib
位于 /usr/lib
文件夹中,因此将 libcrypto.35.dylib
库放入 /usr/local/opt/openssl/lib
文件夹中的解决方案非常明显。
结果我通过
创建了一个符号link➜ ln -s /usr/lib/libcrypto.35.dylib /usr/local/opt/openssl/lib/libcrypto.35.dylib
然后我才能够通过 pip
easysnmp
➜ pip install easysnmp
Collecting easysnmp
Using cached https://files.pythonhosted.org/packages/e0/6f/2fd5c9113a488c81aa95f9006744c6998878a80135010f87506638ba6d5c/easysnmp-0.2.5.tar.gz
Installing collected packages: easysnmp
Running setup.py install for easysnmp ... done
Successfully installed easysnmp-0.2.5