2016-11-04 205 views
1

我試圖在mac OS Sierra上安裝python-lzo。我已經使用brew安裝C lzo庫:安裝python-lzo時找不到文件錯誤

$ virtualenv ./env 
$ . ./env/bin/activate 
$ pip install python-lzo 

這給了我下面的輸出:

Collecting python-lzo 
    Using cached python-lzo-1.11.tar.gz 
Building wheels for collected packages: python-lzo 
    Running setup.py bdist_wheel for python-lzo: started 
    Running setup.py bdist_wheel for python-lzo: finished with status 'error' 
    Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/38/v_r4bjvx7dz626x16nh6jcn00000gn/T/pip-build-wDRYjx/python-lzo/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/38/v_r4bjvx7dz626x16nh6jcn00000gn/T/tmp_ueOY4pip-wheel- --python-tag cp27: 
    /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license' 
    warnings.warn(msg) 
    running bdist_wheel 
    running build 
    running build_ext 
    building 'lzo' extension 
    creating build 
    creating build/temp.macosx-10.11-x86_64-2.7 
    clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/lzo -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lzomodule.c -o build/temp.macosx-10.11-x86_64-2.7/lzomodule.o 
    lzomodule.c:35:10: fatal error: 'lzo1x.h' file not found 
    #include <lzo1x.h> 
     ^
    1 error generated. 
    error: command 'clang' failed with exit status 1 

    ---------------------------------------- 
    Running setup.py clean for python-lzo 
Failed to build python-lzo 
Installing collected packages: python-lzo 
    Running setup.py install for python-lzo: started 
    Running setup.py install for python-lzo: finished with status 'error' 
    Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/38/v_r4bjvx7dz626x16nh6jcn00000gn/T/pip-build-wDRYjx/python-lzo/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/38/v_r4bjvx7dz626x16nh6jcn00000gn/T/pip-8RUWxo-record/install-record.txt --single-version-externally-managed --compile: 
    /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license' 
     warnings.warn(msg) 
    running install 
    running build 
    running build_ext 
    building 'lzo' extension 
    creating build 
    creating build/temp.macosx-10.11-x86_64-2.7 
    clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/lzo -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lzomodule.c -o build/temp.macosx-10.11-x86_64-2.7/lzomodule.o 
    lzomodule.c:35:10: fatal error: 'lzo1x.h' file not found 
    #include <lzo1x.h> 
      ^
    1 error generated. 
    error: command 'clang' failed with exit status 1 

    ---------------------------------------- 

brew update 
brew install lzo 

然後我使用虛擬環境和pip嘗試安裝python-lzo

lzo1x.h文件確實存在於此處:/usr/local/opt/lzo/include/lzo/或與brew命令:

$ ls $(brew --prefix lzo)/include/lzo/ 

我已經然後試圖設置CFLAGS envronment變量,但仍然有同樣的錯誤:

$ export EXTRA_CFLAGS=-I/usr/local/opt/lzo/include && export EXTRA_CXXFLAGS=-I/usr/local/opt/lzo/include && export EXTRA_LDFLAGS=-L/usr/local/opt/lzo/lib && pip install 

而且在絕望:

$ export EXTRA_CFLAGS=-I/usr/local/opt/lzo/include/lzo && export EXTRA_CXXFLAGS=-I/usr/local/opt/lzo/include/lzo && export EXTRA_LDFLAGS=-L/usr/local/opt/lzo/lib && pip install python-lzo 

還是一樣的錯誤消息,有什麼想法?

- Updated--
也試過直接傳遞變量到pip

pip install --global-option='build_ext' --global-option='-I/usr/local/opt' --global-option='-I/usr/local/opt/lzo/include/lzo' --global-option='-L/usr/local/opt/lzo/lib' python-lzo 

這一次,我得到一個稍微不同的錯誤:

cmdoptions.check_install_build_global(options) 
Collecting python-lzo 
    Using cached python-lzo-1.11.tar.gz 
Skipping bdist_wheel for python-lzo, due to binaries being disabled for it. 
Installing collected packages: python-lzo 
    Running setup.py install for python-lzo ... error 
    Complete output from command /Users/myuser/dir/devel/lzo_example/env/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/38/v_r4bjvx7dz626x16nh6jcn00000gn/T/pip-build-14vN3V/python-lzo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/usr/local/opt -I/usr/local/opt/lzo/include/lzo -L/usr/local/opt/lzo/lib install --record /var/folders/38/v_r4bjvx7dz626x16nh6jcn00000gn/T/pip-Gq5pjs-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/emson/Dropbox/devel/aws/coursenut_bigdata/lzo_example/env/bin/../include/site/python2.7/python-lzo: 
    /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license' 
     warnings.warn(msg) 
    running build_ext 
    building 'lzo' extension 
    creating build 
    creating build/temp.macosx-10.11-x86_64-2.7 
    clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/lzo -I/usr/local/opt/lzo/include/lzo -I/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lzomodule.c -o build/temp.macosx-10.11-x86_64-2.7/lzomodule.o 
    In file included from lzomodule.c:35: 
    /usr/local/opt/lzo/include/lzo/lzo1x.h:33:10: fatal error: 'lzo/lzoconf.h' file not found 
    #include <lzo/lzoconf.h> 
      ^
    1 error generated. 
    error: command 'clang' failed with exit status 1 

非常感謝

- SUCCESS ---

非常感謝@daphtdazz您的解決方案(見下文)工作! 我已經修改了它稍微使用brew --cellar命令來獲取lzo文件的位置:

export C_INCLUDE_PATH=$(brew --cellar lzo)/2.09/include/lzo:$(brew --cellar lzo)/2.09/include/ export LIBRARY_PATH=/usr/local/lib pip install python-lzo

回答

4

我得到了相同的結果,你,並最終這個工作對我來說:

export C_INCLUDE_PATH=/usr/local/Cellar/lzo/2.09/include/lzo:/usr/local/Cellar/lzo/2.09/include 
export LIBRARY_PATH=/usr/local/lib 
pip install python-lzo 

(很明顯,你可能需要調整那些依賴於已安裝什麼lzo BREW分發的版本。)

哪個回答了這個問題對我來說,但我真的不明白,爲什麼那些配置不正確......

我已經安裝了Xcode開發工具,雖然還有,我認爲他們」與之前的brewpip衝突,所以也許就是這樣。我會繼續看看,如果我解決了,我會更新這個答案。

編輯

有一個看看setup.py文件python-lzo似乎有有點古怪的事情,尤其是我所關心的是在Windows上包括被添加的路徑,這表明了lzo來源分佈不是很好安排。但似乎沒有一種設計方式可以在brew上安裝,因此我認爲它的包含部分至少可以通過額外的環境變量來解決。

+0

非常棒的作品!非常感謝。我稍微修改了你的版本以使用'brew --cellar'命令,因此:'export C_INCLUDE_PATH = $(brew --cellar lzo)/2.09/include/lzo:$(brew --cellar lzo)/2.09/include/; export LIBRARY_PATH =/usr/local/lib; pip install python-lzo' – emson

+0

將2.09更改爲2.10以備以後使用brew數據庫 –

0

我不使用MacOS的,但你可以嘗試給ENV。變量直接到PIP?

所以,你在第二次嘗試(沒有導出),但沒有& &相同的命令。

foo=bar pim=pam pip install ...

另外,你檢查了丟失的文件在您包括目錄存在?

+0

謝謝邁克爾....我試着把它們作爲全局選項參數例如pip install --global-option ='build_ext'--global-option =' - I/usr/local/opt'--global-option =' - I/usr/local/opt/lzo/include/lzo' - -global-option =' - L/usr/local/opt/lzo/lib'python-lzo但是仍然收到類似的錯誤 - 查看上面更新 – emson

相關問題