在 Ubuntu 14.04.02 上使用 pip 安装 Fuel(机器学习)

Installing Fuel (Machine Learning) using pip on Ubuntu 14.04.02

安装 Fuel machine learning 库时,我遇到了一些依赖项问题:

alvas@ubi:~$ pip install --upgrade git+git://github.com/mila-udem/fuel.gitYou are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting git+git://github.com/mila-udem/fuel.git
  Cloning git://github.com/mila-udem/fuel.git to /tmp/pip-xUlqCT-build
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting numpy (from fuel==0.0.1)
Requirement already up-to-date: six in /usr/local/lib/python2.7/dist-packages (from fuel==0.0.1)
Collecting picklable-itertools (from fuel==0.0.1)
  Downloading picklable-itertools-0.1.1.tar.gz
Collecting pyyaml (from fuel==0.0.1)
  Downloading PyYAML-3.11.tar.gz (248kB)
    100% |████████████████████████████████| 249kB 612kB/s 
Collecting h5py (from fuel==0.0.1)
  Downloading h5py-2.5.0.tar.gz (684kB)
    100% |████████████████████████████████| 688kB 398kB/s 
Collecting tables (from fuel==0.0.1)
  Downloading tables-3.2.2.tar.gz (7.0MB)
    100% |████████████████████████████████| 7.0MB 73kB/s 
    Complete output from command python setup.py egg_info:
    /usr/bin/ld: cannot find -lhdf5
    collect2: error: ld returned 1 exit status
    * Using Python 2.7.6 (default, Jun 22 2015, 17:58:13)
    * USE_PKGCONFIG: True
    .. ERROR:: Could not find a local HDF5 installation.
       You may need to explicitly state where your local HDF5 headers and
       library can be found by setting the ``HDF5_DIR`` environment
       variable or by using the ``--hdf5`` command-line option.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wMS1d3/tables

然后在我完成之后(Installing h5py on an Ubuntu server):

sudo apt-get install libhdf5-dev
sudo HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ pip install h5py

然后我还必须更新我的 cython:

sudo pip install cython

我的问题不是关于如何解决安装问题,而是这个命令是什么意思?

sudo HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ pip install h5py

指定 HDF5_DIR 有什么作用?

为什么没有从 :

自动安装燃料依赖项

我应该怎么做才能从 fuel 更新 setup.py 以便它可以自动 pip 安装依赖项?

您无需对来自 fuel 的 setup.py 进行任何修改。在更新库之前确保 HDF5_DIR 设置正确。

解释:

如果你查看你的错误日志,你可以看到它在安装 h5py python lib 时失败,它是 fuel 的依赖项。它还告诉你为什么最后失败了,基本上是因为 h5py 使用了 C 库 hdf5 并且它需要这个库的 headers 才能使用它。 所以你执行的sudo apt-get install libhdf5-dev是安装这个C库的开发版本(你可以通过-dev来判断)。开发版本安装库的 headers 而不仅仅是编译后的库。 然后,需要 HDF5_DIR env 变量来告诉 h5py 安装程序在哪里可以找到那些 headers.

因此,如果您下次要更新燃料库,请确保 HDF5_DIR 设置正确,然后它将更新其依赖项(包括 h5py)。