欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

关于在mac上plyvel安装失败的问题

程序员文章站 2024-03-21 14:36:40
...

总结

安装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

就可以顺利完成安装