Mac OS X:无法通过pip安装easysnmp

时间:2019-06-28 08:36:07

标签: python macos pip easysnmp

我正在尝试在Mac OS上通过pip安装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/

我使用pyenvpython 3.6.5pip 19.1.1Mac OS Mojave 10.14.3。此外,我已经安装了net-snmp 5.8gcc 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

在通过easysnmp安装依赖项之后,我在Ubuntu上成功安装了apt-get install -y libsnmp-dev snmp libyaml-dev gcc,但是还没有找到Mac OS的替代方案。我将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:0)

最后,我找到了一个解决方案,似乎我的/usr/local/opt/openssl/lib文件夹不包含libcrypto.35.dylib库。 Fortunatelly libcrypto.35.dylib位于/usr/lib文件夹中,因此将libcrypto.35.dylib库放入/usr/local/opt/openssl/lib文件夹中的解决方案非常明显。

结果,我通过创建了一个符号链接

➜ ls -s /usr/lib/libcrypto.35.dylib /usr/local/opt/openssl/lib/libcrypto.35.dylib

直到那时,我才能够通过easysnmp安装pip

➜ 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