Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pip安装python lzo时出现文件未找到错误_Python_Macos Sierra_Lzo - Fatal编程技术网

pip安装python lzo时出现文件未找到错误

pip安装python lzo时出现文件未找到错误,python,macos-sierra,lzo,Python,Macos Sierra,Lzo,我正试图在mac OS上安装python lzo。我使用brew安装了clzo库: brew update brew install lzo 然后,我尝试使用虚拟环境和pip安装pythonlzo: $ virtualenv ./env $ . ./env/bin/activate $ pip install python-lzo pip install --global-option='build_ext' --global-option='-I/usr/local/opt' --glob

我正试图在mac OS上安装
python lzo
。我使用
brew
安装了c
lzo
库:

brew update
brew install lzo
然后,我尝试使用虚拟环境和
pip
安装
pythonlzo

$ virtualenv ./env
$ . ./env/bin/activate
$ pip install python-lzo
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
这给了我以下输出:

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

    ----------------------------------------
然后我尝试设置
CFLAGS
environment变量,但仍然有相同的错误:

$ 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
还是相同的错误信息,有什么想法吗

--更新--
还尝试将变量直接传递到
pip

$ virtualenv ./env
$ . ./env/bin/activate
$ pip install python-lzo
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
cmdoptions。检查\u安装\u构建\u全局(选项)
收集python lzo
使用缓存的python-lzo-1.11.tar.gz
正在跳过PythonLzo的bdist_控制盘,因为它禁用了二进制文件。
安装收集的软件包:pythonlzo
正在为python lzo运行setup.py安装。。。错误
从command/Users/myuser/dir/devel/lzo_example/env/bin/python2.7-u-c“import setuptools,tokenize;_ufile_uu='/private/var/folders/38/v_R4bjvx7dz626x16nh6jcn0000gn/T/pip-build-14vN3V/python lzo/setup.py';f=getattr(tokenize,'open,'open,'open)(u文件);code=f.read()。替换('r\n','n';关闭,'exec,'execu文件,'execu'))"build_ext-I/usr/local/opt-I/usr/local/opt/lzo/include/lzo-L/usr/local/opt/lzo/lib安装--record/var/folders/38/v_r4bjvx7dz626x16nh6jcn0000gn/T/pip-Gq5pjs-record/install-record.txt--外部管理的单一版本--编译--安装头文件/Users/emson/Dropbox/devel/aws/coursenut\u bigdata/lzo\u example/env/bin/。/include/site/python2.7/python-lzo:
/usr/local/ceral/python/2.7.12/Frameworks/python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:251:UserWarning:“license”分发选项已被弃用;使用“许可证”
警告。警告(msg)
运行build_ext
建筑“lzo”扩建
创建构建
创建构建/临时macosx-10.11-x86_64-2.7
clang-fno严格别名-fno common-dynamic-g-O2-DNDEBUG-g-fwrapv-O3-Wall-Wstrict原型-I/usr/include/lzo-I/usr/local/opt/lzo/include/lzo-I/usr/local/cell/python/2.7.12/Frameworks/python.framework/Versions/2.7/include/python2.7-c lzomodule.c-o-build/temp.macosx-10.11-x86-2.7/lzomodule.o
在lzomodule.c:35中包含的文件中:
/usr/local/opt/lzo/include/lzo/lzo1x.h:33:10:致命错误:找不到“lzo/lzoconf.h”文件
#包括
^
生成1个错误。
错误:命令“clang”失败,退出状态为1
非常感谢

--成功--

非常感谢@Daphtdaz您的解决方案(见下文)奏效了! 我稍微修改了它,使用
brew--ceral
命令获取
lzo
文件的位置:


导出C_INCLUDE_PATH=$(brew--cellar lzo)/2.09/INCLUDE/lzo:$(brew--cellar lzo)/2.09/INCLUDE/
导出库路径=/usr/local/lib
pip安装pythonlzo

我不使用MacOS,但是你能试着给我环境吗。直接向PIP发送变量

因此,使用与第二次尝试相同的命令(不带导出),但不带&

foo=bar-pim=pam-pip安装…


另外,您是否检查了您包含的目录中是否存在丢失的文件?

我得到了与您相同的结果,最终这对我起到了作用:

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开发工具,我认为它们与以前的
brew
pip
有冲突,所以可能就是这样。我会继续看,如果我解决了,我会更新这个答案

编辑


看看
pythonlzo
的文件,似乎有点奇怪,特别是我担心在Windows上都添加了include路径,这表明
lzo
源代码分发没有很好地安排。但在macOS上安装brew似乎没有一种设计好的方法来实现这一点,因此我认为至少使用额外的环境变量来解决其中的include部分是最好的。

谢谢Michael。。。。我曾尝试将它们作为全局选项参数传递,例如pip安装--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,但仍然得到一个类似的错误-请参阅上面的更新,这是可行的!非常感谢。我稍微修改了您的版本,使用了
brew--cillar
命令,因此:
export C_INCLUDE_PATH=$(brew--cillar lzo)/2.09/INCLUDE/lzo:$(brew--cillar lzo)/2.09/INCLUDE/;导出库路径=/usr/local/lib;pip安装python lzo
将2.09更改为2.10以用于更高版本的brew数据库