gpt4 book ai didi

python - 如何在没有 conda 的情况下从源代码安装 Bob

转载 作者:太空宇宙 更新时间:2023-11-03 13:59:42 32 4
gpt4 key购买 nike

Bob推荐其用户到install它的包使用conda ,
但我不想使用 conda .如何从源代码安装它?

最佳答案

解释

首先,使用 conda 安装 Bob 要容易得多,并且是安装 Bob 的受支持方式。请再次考虑使用 conda 安装 Bob,然后再继续。 Bob 是用 C++ 和 Python 混合编写的,并链接到许多不同的 C/C++ 库,而 Conda 是一个与语言无关的二进制包管理器,可以处理所有这些。

如果要从源代码安装 Bob,首先需要手动安装其依赖项。每个包的依赖项都列在每个 Bob 包的 conda 配方中。从其 conda 配方中,您必须安装(如果存在)requirements:build , requirements:host , requirements:run , 和 test:requires .这些包是 conda 包而不是 pip 包;其中一些可能是 pip 包(名称可能不同),其中一些可能只是一个 C/C++ 库,您应该使用系统的包管理器(或从源代码)安装它。

例如,bob.extension 的 conda 配方是 here :

requirements:
host:
- python {{ python }}
- setuptools {{ setuptools }}
run:
- python
- setuptools
- click
- click-plugins

test:
requires:
- bob-devel {{ bob_devel }}.*
- nose
- coverage
- sphinx
- sphinx_rtd_theme
- boost
- cmake
- pkg-config
- freetype
- libblitz
- numpy
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- bob.buildout

解析这个配方意味着你需要安装: boost , cmake , pkg-config , freetype , libblitz , C and C++ compilers , 可能是 numpy首先使用系统的包管理器,然后安装 click , click-plugins , nose , coverage , sphinx , sphinx_rtd_theme , 和 bob.buildout与点。 (您还可以查看 Bob 包的 requirements.txttest-requirements.txt 以获取依赖项的 pip 包名称,但可能不会更新以匹配其 conda 配方)。 bob-devel是一个 conda 元包,您在不使用 conda 时不需要安装它。

这将设置您的环境以准备编译(如果需要)、安装和测试 bob.extension .搭建好环境后,可以使用pip安装 bob.extension :
pip install bob.extension

然后,您需要按照 Bob 包依赖项的顺序安装下一个 Bob 包。正如您所看到的,这可能非常耗时,但这是唯一可行的方法,因为 Bob 的包已开发并且它们的依赖关系已更改。

指示

这些说明将帮助您安装大多数包含难以安装的 C++ 代码的 Bob 包。安装完这些包后,您很可能可以使用 pip 安装其余的 Bob 包。

依赖项

您需要首先使用系统的包管理器安装 Bob 包依赖项。
+-------------+------+-------------------------+---------------------+
| Library | Min. | License | Notes |
| | Vers | | |
| | io | | |
| | n | | |
+=============+======+=========================+=====================+
| Std. C/C++ | any | Depends on the compiler | Required by all |
| Libraries | | | packages with C/C++ |
| | | | bindings |
+-------------+------+-------------------------+---------------------+
| `Blitz++ <h | 0.10 | `Artistic-2.0 <http://w | Required by all |
| ttp://www.o | | ww.opensource.org/licen | packages with C/C++ |
| onumerics.o | | ses/Artistic-2.0>`__ | bindings |
| rg/blitz>`_ | | or LGPLv3+ or GPLv3+ | |
| _ | | | |
+-------------+------+-------------------------+---------------------+
| `Lapack <ht | any | BSD-style | Required by |
| tp://www.ne | | | ``bob.math`` |
| tlib.org/la | | | |
| pack>`__ | | | |
+-------------+------+-------------------------+---------------------+
| `Python <ht | 2.5 | `Python-2.0 <http://www | Required by all |
| tp://www.py | | .opensource.org/license | packages |
| thon.org>`_ | | s/Python-2.0>`__ | |
| _ | | | |
+-------------+------+-------------------------+---------------------+
| `Boost <htt | 1.34 | `BSL-1.0 <http://www.op | Required by all |
| p://www.boo | | ensource.org/licenses/B | packages with C/C++ |
| st.org>`__ | | SL-1.0>`__ | bindings |
+-------------+------+-------------------------+---------------------+
| `HDF5 <http | 1.8. | `HDF5 | Required by all I/O |
| ://www.hdfg | 4 | License <ftp://ftp.hdfg | operations (direct |
| roup.org/HD | | roup.org/HDF5/current/s | or indirect |
| F5>`__ | | rc/unpacked/COPYING>`__ | dependencies to |
| | | (BSD-like, 5 clauses) | ``bob.io.base``) |
+-------------+------+-------------------------+---------------------+
| `libpng <ht | 1.2. | `libpng | Required by all |
| tp://libpng | 42 | license <http://www.lib | packages that do |
| .org/pub/pn | ? | png.org/pub/png/src/lib | image I/O and |
| g/libpng.ht | | png-LICENSE.txt>`__ | manipulation |
| ml>`__ | | | (depend directly or |
| | | | indirectly on |
| | | | ``bob.io.image``) |
+-------------+------+-------------------------+---------------------+
| `libtiff <h | 3.9. | BSD-style | Required by all |
| ttp://www.r | 2 | | packages that do |
| emotesensin | | | image I/O and |
| g.org/libti | | | manipulation |
| ff/>`__ | | | (depend directly or |
| | | | indirectly on |
| | | | ``bob.io.image``) |
+-------------+------+-------------------------+---------------------+
| `giflib <ht | 4.1. | `MIT <http://www.openso | Required by all |
| tp://giflib | 6-9 | urce.org/licenses/MIT>` | packages that do |
| .sourceforg | | __ | image I/O and |
| e.net/>`__ | | | manipulation |
| | | | (depend directly or |
| | | | indirectly on |
| | | | ``bob.io.image``) |
+-------------+------+-------------------------+---------------------+
| `libjpeg <h | 6.2? | `GPL-2.0 <http://www.op | Required by all |
| ttp://libjp | | ensource.org/licenses/G | packages that do |
| eg.sourcefo | | PL-2.0>`__ | image I/O and |
| rge.net/>`_ | | or later (also | manipulation |
| _ | | commercial) | (depend directly or |
| | | | indirectly on |
| | | | ``bob.io.image``) |
+-------------+------+-------------------------+---------------------+
| `FFMpeg <ht | 0.5 | `LGPL-2.1 <http://www.o | Required by all |
| tp://ffmpeg | (ffm | pensource.org/licenses/ | packages that do |
| .org>`__ | pe | LGPL-2.1>`__ | video I/O and |
| or | g) | or later, or | manipulation |
| `libAV <htt | or | `GPL-2.0 <http://www.op | (depend directly or |
| p://libav.o | 0.8 | ensource.org/licenses/G | indirectly on |
| rg>`__ | (lib | PL-2.0>`__ | ``bob.io.video``) |
| | av | or later | |
| | ) | | |
+-------------+------+-------------------------+---------------------+
| `MatIO <htt | 1.3. | `BSD-2-Clause <http://w | Required by all |
| p://matio.s | 3? | ww.opensource.org/licen | packages that do |
| ourceforge. | | ses/BSD-2-Clause>`__ | Matlab I/O and |
| net>`__ | | | manipulation |
| | | | (depend directly or |
| | | | indirectly on |
| | | | ``bob.io.matlab``) |
+-------------+------+-------------------------+---------------------+
| `VLFeat <ht | 0.9. | `BSD-2-Clause <http://w | Required by |
| tp://www.vl | 14 | ww.opensource.org/licen | ``bob.ip.base`` and |
| feat.org/>` | | ses/BSD-2-Clause>`__ | all dependents |
| __ | | | |
+-------------+------+-------------------------+---------------------+
| `LIBSVM <ht | 2.89 | `BSD-3-Clause <http://w | Required by |
| tp://www.cs | + | ww.opensource.org/licen | ``bob.learn.libsvm` |
| ie.ntu.edu. | | ses/BSD-3-Clause>`__ | ` |
| tw/~cjlin/l | | | and all dependents |
| ibsvm/>`__ | | | |
+-------------+------+-------------------------+---------------------+
| `CMake <htt | 2.8 | `BSD-3-Clause <http://w | Required by all |
| p://www.cma | | ww.opensource.org/licen | packages with C/C++ |
| ke.org>`__ | | ses/BSD-3-Clause>`__ | bindings. **Use at |
| | | | least CMake 2.8.12 |
| | | | on Mac OS X**. |
+-------------+------+-------------------------+---------------------+
| `pkg-config | any | `GPL-2.0 <http://www.op | Required to find |
| <http://ww | | ensource.org/licenses/G | dependencies while |
| w.freedeskt | | PL-2.0>`__ | building bob |
| op.org/wiki | | | packages. |
| /Software/p | | | |
| kg-config/> | | | |
| `__ | | | |
+-------------+------+-------------------------+---------------------+

安装依赖项后,您可以使用 pip 从源代码安装。

可以使用 pip 安装软件包,全局或在您的私有(private) virtualenv ,如果这是您喜欢 Python 工作环境的方式。你
将需要手动安装您需要的所有软件包(直接或间接),
pip/ setuptools目前无法连贯地安装 Python
相互依赖构建的软件包,例如许多
包。

例如,要安装 bob.io.image在一个新创建的虚拟
环境,这是要执行的命令序列:
$ pip install numpy
$ pip install bob.extension
$ pip install bob.blitz
$ pip install bob.core
$ pip install bob.io.base
$ pip install bob.io.image

每个 pip命令必须单独执行,尊重包间
依赖。

以下将 不是 按预期工作:
$ #Do not do this:
$ pip install numpy bob.io.image

核心包的依赖可以概括为7层
以下脚本可用于安装所有使用 pip 的核心包:
$ bash pip_install_bob.sh
-------------------------
#!/bin/bash
set -e

get_layer() {
case $1 in
1)
packages=("bob.extension")
;;
2)
packages=("bob.blitz")
;;
3)
packages=("bob.core" "bob.ip.draw")
;;
4)
packages=("bob.io.base" "bob.sp" "bob.math")
;;
5)
packages=("bob.ap" "bob.measure" "bob.db.base" "bob.io.image" "bob.io.video" "bob.io.matlab" "bob.ip.base" "bob.ip.color" "bob.ip.gabor" "bob.learn.activation" "bob.learn.libsvm" "bob.learn.boosting")
;;
6)
packages=("bob.io.audio" "bob.learn.linear" "bob.learn.mlp" "bob.db.wine" "bob.db.mnist" "bob.db.atnt" "bob.ip.flandmark" "bob.ip.facedetect" "bob.ip.optflow.hornschunck" "bob.ip.optflow.liu")
;;
7)
packages=("bob.learn.em" "bob.db.iris")
;;
esac
}

for layer in `seq 1 7`;
do
get_layer ${layer}
for pkg in "${packages[@]}";
do
pip install $pkg
done
done

为了加快最后一个脚本中的编译速度,您可以在并行线程中进行编译。只需设置一个环境变量 BOB_BUILD_PARALLEL=N在哪里 N是您机器上的最大并行进程数。

关于python - 如何在没有 conda 的情况下从源代码安装 Bob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50803148/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com