8

I create a new conda environment

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
#

and then activate it and attempt to use specifically pip (not conda) to install llvmlite and numba, which appears to succeed. (Note: I've tried also --no-cache-dir and it doesn't change anything.)

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

But the library is not installed properly,

(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

Why does the conda installation of llvmdev from the numba channel fail to "just work".

In my use case, I'm coming to a project that has a pip-styled requirements.txt file, and I need to create conda environments from that file. Some project developers will use venv+pip, some will use conda, and some packages it contains are not found in any anaconda channels, so pip installation is mandatory. We don't want to maintain a separate envrionment.yaml in addition to the requirements.txt, so installing from requirements.txt inside of a conda envrionment is part of my constraints.

Everything seems OK, except for the pip installation of numba/llvmlite, which expects a system dependency of llvm 3.8+. I want to satisfy that as part of the conda environment though.

How can I ensure from a conda environment only that the right llvmdev exists for installing numba and llvmlite?

ely
  • 74,674
  • 34
  • 147
  • 228
  • I cannot reproduce your error on an Ubuntu VM, but you might try pulling from the conda-forge channel instead of the numba dev channel and see if that helps. – JoshAdel Feb 06 '17 at 19:39
  • I can reproduce it locally on a Ubuntu 16.10 machine, and also on a remote Centos7 machine.Haven't tried others yet. – ely Feb 06 '17 at 19:41
  • What version of conda are you using? "conda config -a" are you pulling from opensource channels or some internal mirror? – Kelvin Feb 10 '17 at 20:41
  • 1
    Using conda 4.6.2: `conda create -n test -c numba -c defaults --override-channels numba llvmdev llvmlite`, then `conda activate test`, then `python -m numba` gives ``OSError: /lib64/libpthread.so.0: version `GLIBC_2.12' not found (required by /hpc/uhome/gholl/miniconda3/envs/test/lib/python3.7/site-packages/llvmlite/binding/libllvmlite.so`` and `OSError: libllvmlite.so: cannot open shared object file: No such file or directory`. The file `/hpc/uhome/gholl/miniconda3/envs/test/lib/python3.7/site-packages/llvmlite/binding/libllvmlite.so` exists. Not sure if this is the same problem. – gerrit Feb 11 '19 at 10:15
  • 1
    My problem is [probably a different one](https://stackoverflow.com/q/33655731/974555). – gerrit Feb 11 '19 at 10:19

3 Answers3

3

Installing llvmdev: Installing llvmdev from the conda-forge channel can be achieved by adding conda-forge to your channels with:

conda config --add channels conda-forge

Once the conda-forge channel has been enabled, llvmdev can be installed with:

conda install llvmdev

It is possible to list all of the versions of llvmdev available on your platform with:

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
bob marti
  • 1,523
  • 3
  • 11
  • 27
3

This is what worked for me using the Anaconda environment:

pip uninstall llvmlite
pip install -U --ignore-installed numba
Hagbard
  • 3,430
  • 5
  • 28
  • 64
1

In an ideal scenario, the required shared library should be present after the installation of llvmlite.

(test-env) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
(test-env) ~/condaexpts$ source activate test-env
(test-env) ~/condaexpts$ pip install numpy==1.12.0 llvmlite==0.15 numba==0.30.1
(test-env) ~/condaexpts$ find $CONDA_PREFIX | grep libllvmlite
/home/ubuntu/condaexpts/m3/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so

If this file is not present in the test-env, then something went wrong while installing llvmlite.

Also, think about this approach the other way round. You don't need to have a requirements file separate from conda environment file. You can have both dependencies in the conda environment file itself:

(test-env) ~/condaexpts$ conda env export               
name: test-env
channels:
- !!python/unicode
  'numba'
- !!python/unicode
  'defaults'
dependencies:
- !!python/unicode
  'openssl=1.0.2k=0'
- !!python/unicode
  'pip=9.0.1=py35_1'
- !!python/unicode
  'python=3.5.2=0'
- !!python/unicode
  'readline=6.2=2'
- !!python/unicode
  'setuptools=27.2.0=py35_0'
- !!python/unicode
  'sqlite=3.13.0=0'
- !!python/unicode
  'tk=8.5.18=0'
- !!python/unicode
  'wheel=0.29.0=py35_0'
- !!python/unicode
  'xz=5.2.2=1'
- !!python/unicode
  'zlib=1.2.8=3'
- !!python/unicode
  'llvmdev=3.8.1=7'
- !!python/unicode
  'system=5.8=2'
- pip:
  - llvmlite==0.15.0
  - numba==0.30.1
  - numpy==1.12.0
prefix: !!python/unicode '/home/ubuntu/condaexpts/m3/envs/test-env'

On second note, you can install the pre-built binaries required from the 'numba' conda channel itself. With:

(root) ~/condaexpts$ ./Miniconda3-latest-Linux-x86_64.sh -b -p m3
(root) ~/condaexpts$ source ./m3/bin/activate 
(root) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8 numba=0.30.1 llvmlite=0.15.0
(root) ~/condaexpts$ source activate test-env
(test-env) ~/condaexpts$ 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
>>> numba.__version__
'0.30.1'
Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89
  • Thanks for the reply. Unfortunately these options won't work in my scenario. Normally I like to use the anaconda channels to get precompiled binaries, especially for complex dependencies like llvmlite. However, in this current project, it is already based on a pip requirements.txt file. You should assume that I am unable to support a companion environment.yml to use alongside it because of project constraints. – ely Feb 04 '17 at 14:44
  • Also, regarding your first point about the CONDA_PREFIX location for the llvm shared object, look at the first part of the error messages in my question. They show that the shared object, `/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so` does exist (I can easily see it in the file system). However, the precompiled binary installed by conda via `llvmdev` has the missing symbol error, and it's unclear why a conda installed dependency could have that problem. – ely Feb 04 '17 at 14:46