gpt4 book ai didi

python - pip 没有在 conda 环境中正确安装 numba/llvmlite

转载 作者:太空狗 更新时间:2023-10-30 01:26:47 32 4
gpt4 key购买 nike

我创建一个新的conda环境

user@machine:~/project$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /home/user/anaconda2/envs/test-env:

The following NEW packages will be INSTALLED:

llvmdev: 3.8.1-7 numba
openssl: 1.0.2k-0
pip: 9.0.1-py35_1
python: 3.5.2-0
readline: 6.2-2
setuptools: 27.2.0-py35_0
sqlite: 3.13.0-0
system: 5.8-2 numba
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-1
zlib: 1.2.8-3

Proceed ([y]/n)? y

#
# To activate this environment, use:
# > source activate test-env
#
# To deactivate this environment, use:
# > source deactivate test-env
#

然后激活它并尝试专门使用 pip(不是 conda)来安装 llvmlite 和 numba,这似乎成功了。 (注意:我也尝试过 --no-cache-dir 并且它没有改变任何东西。)

user@machine:~/project$ source activate test-env
(test-env) user@machine:~/project$ pip install llvmlite==0.15 numba==0.30.1
Collecting llvmlite==0.15
Collecting numba==0.30.1
Collecting numpy (from numba==0.30.1)
Using cached numpy-1.12.0-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: llvmlite, numpy, numba
Successfully installed llvmlite-0.15.0 numba-0.30.1 numpy-1.12.0

但是库没有正确安装,

(test-env) user@machine:~/project$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 42, in <module>
lib = ctypes.CDLL(os.path.join(_lib_dir, _lib_name))
File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so: undefined symbol: _ZNKSt14error_category23default_error_conditionEi

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/__init__.py", line 9, in <module>
from . import config, errors, runtests, types
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/config.py", line 11, in <module>
import llvmlite.binding as ll
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/__init__.py", line 6, in <module>
from .dylib import *
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/dylib.py", line 4, in <module>
from . import ffi
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 47, in <module>
lib = ctypes.CDLL(_lib_name)
File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory

为什么 conda 从 numba channel 安装 llvmdev 无法“正常工作”。

在我的用例中,我要进入一个具有 pip 样式的 requirements.txt 文件的项目,我需要从该文件创建 conda 环境。有的项目开发者会使用venv+pip,有的会使用conda,而它包含的一些包在任何anaconda channel 都找不到,所以pip安装是必须的。除了 requirements.txt 之外,我们不想维护单独的 envrionment.yaml,因此从 conda envrionment 内的 requirements.txt 安装是我的约束的一部分。

一切似乎都正常,除了 numba/llvmlite 的 pip 安装,它需要 llvm 3.8+ 的系统依赖。不过,我想将其作为 conda 环境的一部分来满足。

我如何才能从 conda 环境中确保仅存在用于安装 numba 和 llvmlite 的正确 llvmdev?

最佳答案

安装 llvmdev:从 conda-forge channel 安装 llvmdev 可以通过将 conda-forge 添加到您的 channel 来实现:

conda config --add channels conda-forge

启用 conda-forge channel 后,可以安装 llvmdev:

conda install llvmdev

可以列出您平台上可用的所有 llvmdev 版本:

conda search llvmdev --channel conda-forge

HELP:I cloned the relevant files from their GitHub sources and did

 python setup.py install 

for more without conda use pip

 sudo pip install -U llvmlite
sudo pip install -U numba

关于python - pip 没有在 conda 环境中正确安装 numba/llvmlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42033249/

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