从 pip 安装时找不到文件

从 pip 安装时找不到文件

我一直在尝试解决在 Lubuntu 17.04 中安装 python 包时发现的一个问题。

该软件包适用于 python 3.5 64 位。它被称为 RawPy,依赖于 LibRaw 库。我已经安装了 LibRaw 库,但在尝试安装 RawPy 时,无法找到 LibRaw 安装的一些文件:

lubuntu@lubuntu:~$ sudo -H pip3 install rawpy
Collecting rawpy
  Using cached rawpy-0.9.0.tar.gz
Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages (from rawpy)
Building wheels for collected packages: rawpy
  Running setup.py bdist_wheel for rawpy ... error
  Complete output from command /usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pyqrhjz2/rawpy/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 /tmp/tmp9a3kr8dtpip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/rawpy
  copying rawpy/__init__.py -> build/lib.linux-x86_64-3.5/rawpy
  copying rawpy/_version.py -> build/lib.linux-x86_64-3.5/rawpy
  copying rawpy/enhance.py -> build/lib.linux-x86_64-3.5/rawpy
  running build_ext
  building 'rawpy._rawpy' extension
  creating build/temp.linux-x86_64-3.5
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-7CCmgg/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_HAS_LIBRAW_CONFIG_H=0 -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c _rawpy.cpp -o build/temp.linux-x86_64-3.5/_rawpy.o
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  In file included from /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1788:0,
                   from /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                   from /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from _rawpy.cpp:482:
  /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   #warning "Using deprecated NumPy API, disable it by " \
    ^~~~~~~
  In file included from _rawpy.cpp:484:0:
  def_helper.h:1:28: fatal error: libraw_version.h: No such file or directory
   #include "libraw_version.h"
                              ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for rawpy
  Running setup.py clean for rawpy
Failed to build rawpy
Installing collected packages: rawpy
  Running setup.py install for rawpy ... error
    Complete output from command /usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pyqrhjz2/rawpy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-byii91yd-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/rawpy
    copying rawpy/__init__.py -> build/lib.linux-x86_64-3.5/rawpy
    copying rawpy/_version.py -> build/lib.linux-x86_64-3.5/rawpy
    copying rawpy/enhance.py -> build/lib.linux-x86_64-3.5/rawpy
    running build_ext
    building 'rawpy._rawpy' extension
    creating build/temp.linux-x86_64-3.5
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-7CCmgg/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -D_HAS_LIBRAW_CONFIG_H=0 -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c _rawpy.cpp -o build/temp.linux-x86_64-3.5/_rawpy.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1788:0,
                     from /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                     from /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from _rawpy.cpp:482:
    /usr/local/lib/python3.5/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it by " \
      ^~~~~~~
    In file included from _rawpy.cpp:484:0:
    def_helper.h:1:28: fatal error: libraw_version.h: No such file or directory
     #include "libraw_version.h"
                                ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pyqrhjz2/rawpy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-byii91yd-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-pyqrhjz2/rawpy/
lubuntu@lubuntu:~$

我已检查,发现 usr/local/lib/libraw 中存在缺失文件。尝试使用 ldconfig 添加该路由,但没有成功。

LibRaw 似乎已安装。当我写入时ldconfig -p,我得到:

libraw1394.so.11 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libraw1394.so.11
libraw_r.so.16 (libc6,x86-64) => /usr/local/lib/libraw_r.so.16
libraw_r.so.16 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libraw_r.so.16
libraw_r.so (libc6,x86-64) => /usr/local/lib/libraw_r.so
libraw.so.16 (libc6,x86-64) => /usr/local/lib/libraw.so.16
libraw.so.16 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libraw.so.16
libraw.so (libc6,x86-64) => /usr/local/lib/libraw.so

确实如此:

lubuntu@lubuntu:~$ sudo apt install libraw-dev 
Reading package lists... 
Done Building dependency tree        
Reading state information... 
Done libraw-dev is already the newest version (0.18.1-1). 
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 
lubuntu@lubuntu:~$

该文件的位置如下:

lubuntu@lubuntu:~$ sudo find / -name libraw_version.h
/usr/include/libraw/libraw_version.h
/usr/local/include/libraw/libraw_version.h
/home/lubuntu/libraw/libraw/libraw_version.h
find: ‘/run/user/999/gvfs’: Permission denied
lubuntu@lubuntu:~$

第三个位置是来自 GitHub 的源代码下载文件夹。我也编译了最后一个版本的代码,但没有成功

有没有办法明确告诉 pip 在特定路径中查找依赖项?我甚至想过更改源代码以明确说明路径,但我不认为这是正确的解决方法。

有人有什么想法吗?

答案1

免责声明:我是 rawpy 的开发者。

我不确定您遇到的具体问题,但我最近发布了一个新版本,它为 Linux(除了 Windows 和 macOS)提供了二进制包(wheels),因此不再需要编译或手动安装 libraw。只需重新安装 rawpy,它就可以立即使用。

答案2

尝试 echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/99local.conf

其次是sudo ldconfig

这是从 rawpy 的安装说明。

相关内容