安装plyvel时需要用到leveldb开发库
所以在安装plyvel前,要先安装leveldb
我在直接运行pip install plyvel
时
出现了一长串报错
Defaulting to user installation because normal site-packages is not writeable
Collecting plyvel
Using cached plyvel-1.2.0.tar.gz (145 kB)
Building wheels for collected packages: plyvel
Building wheel for plyvel (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/setup.py'"'"'; __file__='"'"'/private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-wheel-dlRXOW
cwd: /private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/
Complete output (18 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.15-x86_64-2.7
creating build/lib.macosx-10.15-x86_64-2.7/plyvel
copying plyvel/_version.py -> build/lib.macosx-10.15-x86_64-2.7/plyvel
copying plyvel/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/plyvel
running build_ext
building 'plyvel._plyvel' extension
creating build/temp.macosx-10.15-x86_64-2.7
creating build/temp.macosx-10.15-x86_64-2.7/plyvel
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c plyvel/_plyvel.cpp -o build/temp.macosx-10.15-x86_64-2.7/plyvel/_plyvel.o -Wall -g -x c++ -std=c++11 -stdlib=libc++
plyvel/_plyvel.cpp:620:10: fatal error: 'leveldb/db.h' file not found
#include "leveldb/db.h"
^~~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for plyvel
Running setup.py clean for plyvel
Failed to build plyvel
Installing collected packages: plyvel
Running setup.py install for plyvel ... error
ERROR: Command errored out with exit status 1:
command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/setup.py'"'"'; __file__='"'"'/private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/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/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-record-ujLw5Y/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/hwan/Library/Python/2.7/include/python2.7/plyvel
cwd: /private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/
Complete output (18 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.15-x86_64-2.7
creating build/lib.macosx-10.15-x86_64-2.7/plyvel
copying plyvel/_version.py -> build/lib.macosx-10.15-x86_64-2.7/plyvel
copying plyvel/__init__.py -> build/lib.macosx-10.15-x86_64-2.7/plyvel
running build_ext
building 'plyvel._plyvel' extension
creating build/temp.macosx-10.15-x86_64-2.7
creating build/temp.macosx-10.15-x86_64-2.7/plyvel
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c plyvel/_plyvel.cpp -o build/temp.macosx-10.15-x86_64-2.7/plyvel/_plyvel.o -Wall -g -x c++ -std=c++11 -stdlib=libc++
plyvel/_plyvel.cpp:620:10: fatal error: 'leveldb/db.h' file not found
#include "leveldb/db.h"
^~~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/setup.py'"'"'; __file__='"'"'/private/var/folders/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-install-3pGhBP/plyvel/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/sy/ymrww60s7wn57zpz7571hgsw0000gn/T/pip-record-ujLw5Y/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/hwan/Library/Python/2.7/include/python2.7/plyvel Check the logs for full command output.
致命错误在下面几行有显示,即找不到’leveldb / db.h’文件
plyvel/_plyvel.cpp:620:10: fatal error: 'leveldb/db.h' file not found
#include "leveldb/db.h"
^~~~~~~~~~~~~~
所以,只要安装leveldb即可解决问题
我是用homebrew来进行安装的
brew install leveldb
然后在运行
pip install plyvel
就可以顺利完成安装