26

Recently, I have had a frustrating time to get python Numba working on Ubuntu or Fedora Linux. The main problem has been with the compilation of llvmlite. What do I need to install for these to compile properly?

Alexis King
  • 43,109
  • 15
  • 131
  • 205
mettw
  • 439
  • 5
  • 10
  • Thank you very much for this post. I asked a question about this few days ago but I did not go an answer (on askubuntu). I will try your solution in 10 hours by now and let you know if it works on my Ubuntu –  Mar 02 '15 at 09:37
  • I wish I can invite you for a nice dinner. You really saved me from death. Thank you very much for this solution that does not exist anywhere. –  Mar 02 '15 at 19:58

10 Answers10

24

The versions I got working at the end were numba-0.17.0 (also 0.18.2) and llvmlite-0.2.2 (also 0.4.0). Here are the relevant dependencies and configuration options on Ubuntu and Fedora.

For Ubuntu 14.04 *Trusty)

sudo apt-get install zlib1g zlib1g-dev libedit libedit-dev llvm-3.8 llvm-3.8-dev llvm-dev
sudo pip install enum34 funcsigs
LLVM_CONFIG=/usr/bin/llvm-config-3.8 pip install llvmlite --user
LLVM_CONFIG=/usr/bin/llvm-config-3.8 pip install numba --user

For Ubuntu 14.10

sudo apt-get install zlib1g zlib1g-dev libedit libedit-dev llvm-3.5 llvm-3.5-dev llvm-dev
pip install enum34 funcsigs
LLVM_CONFIG=/usr/bin/llvm-config-3.5 pip install llvmlite
LLVM_CONFIG=/usr/bin/llvm-config-3.5 pip install numba

For Ubuntu 15.04

sudo apt-get install zlib1g zlib1g-dev libedit2 libedit-dev llvm-3.6 llvm-3.6-dev llvm-dev
pip install enum34 funcsigs
LLVM_CONFIG=/usr/bin/llvm-config-3.6 pip install llvmlite
LLVM_CONFIG=/usr/bin/llvm-config-3.6 pip install numba

For Fedora 21

yum install zlib zlib-devel libstdc++-devel libstdc++ libstdc++-static llvm-3.5.0 llvm-devel-3.5.0 libedit libedit-devel
pip install enum34 funcsigs
LLVM_CONFIG=/usr/bin/llvm-config pip install llvmlite
LLVM_CONFIG=/usr/bin/llvm-config pip install numba

Note: this was originally posted by the OP in the question—moved here to keep this fit for SO.

Vasco
  • 1,177
  • 11
  • 28
Alexis King
  • 43,109
  • 15
  • 131
  • 205
  • 1
    Some library names are a bit different for Ubuntu 14.04. Updating the commands to include them below: sudo apt-get install zlib1g zlib1g-dev libedit2 libedit-dev llvm-3.5 llvm-3.5-dev llvm-dev sudo pip install enum34 funcsigs sudo LLVM_CONFIG=/usr/bin/llvm-config-3.5 pip install llvmlite sudo LLVM_CONFIG=/usr/bin/llvm-config-3.5 pip install numba – Sevak Avakians May 07 '15 at 18:46
  • 1
    Anybody knows how to make this work for Ubuntu 15.04? I tried the 14.10 instruction above and yet it still fails at 'pip install llvmlite' – x112341 May 22 '15 at 12:08
  • This doesn't work for Ubuntu 12.04 as well. Gets stuck in compilation of llvmlite :( – Geekster Jun 18 '15 at 08:11
  • 1
    For Ubuntu 15.04 I switched from llvm 3.5 to llvm 3.6 and things seem to work. So for example, run "LLVM_CONFIG=/usr/bin/llvm-config-3.6 pip install llvmlite" instead. – Paul Sep 25 '15 at 17:06
4

For ubuntu 15.10

fisrt check that pip has the correct version:

pip install --upgrade pip
pip install --upgrade wheel

pip >= 8.1

$ pip --version
pip 8.1.1 from
$ wheel version
wheel 0.29.0

apt-get install llvm stuff:

sudo apt-get install zlib1g zlib1g-dev libedit2 libedit-dev
sudo apt-get install llvm-3.7 llvm-3.7-dev llvm-dev

and then with pip (warning llvmlite work only with llvm 3.7):

pip install enum34 funcsigs
LLVM_CONFIG=/usr/bin/llvm-config-3.7 pip install llvmlite
LLVM_CONFIG=/usr/bin/llvm-config-3.7 pip install numba
Community
  • 1
  • 1
user3313834
  • 7,327
  • 12
  • 56
  • 99
  • This also works for 16.04. In my case, I used python 2.7 and llvm 3.8 (which is compatible with llvmlite 0.13). – noe Sep 30 '16 at 10:53
3

Ubuntu 15.10 using Python 3.4.3+

llvmlite version 0.9 or newer (I installed 0.10)

As stated in llvmlite's GitHub Page:

As of version 0.9, llvmlite requires LLVM 3.7. It does not support earlier or later versions of LLVM.

My solution, similar to the ones in other answers (but regarding python3):

To meet the dependencies: (like libedit and compression libraries)

sudo apt-get install zlib1g zlib1g-dev libedit2 libedit-dev
sudo pip3 install enum34 funcsigs

llvm-3.7 (Other answers included llvm package, which nowadays installs version 3.6, not working)

sudo apt-get install llvm-3.7 llvm-3.7-dev llvm-3.7-runtime llvm-3.7-tools

Trying to install llvmlite from pip:

sudo pip3 install llvmlite

(If it works, skip this) If it doesn't work, like in my case, build the last master branch from their repository:

git clone https://github.com/numba/llvmlite
cd llvmlite/
sudo ch -c "LLVM_CONFIG=/usr/bin/config-3.7 python3 setup.py build
sudo sh -c "LLVM_CONFIG=/usr/bin/llvm-config-3.7 python3 setup.py install"

Finally, install numba:

sudo pip3 install numba
risantos
  • 51
  • 2
  • I'm not sure but the question clearly states using phyton 2.7 Also you have a **huge** formatting (bold...) problem. – cramopy Mar 29 '16 at 15:45
  • @cramopy I provided my solution for Python3, since I've had the same issue and there weren't any other stackoverflow questions regarding it. For the python 2.7 case , instead of `pip3` and `python3`, the use is `pip` and `python`. Sorry for the poor formatting. Thought it could provide some visual aid for future users' troubleshooting. In the meanwhile, I've found [this guide](http://meta.stackexchange.com/questions/18614/style-guide-for-questions-and-answers) to improve my experience here. (1st time I answered something ) – risantos Mar 29 '16 at 23:24
  • `ch` should be `sh` in example. – Kusalananda Jun 26 '16 at 09:24
  • 1
    typo: that probably should be `sudo sh -c "LLVM...` not `sudo ch -c "LLVM...` – michael Jun 26 '16 at 09:26
2

There was a change in llvmlite. Since version llvmlite-0.6.0 llvm-3.6 is required. The correct installation is now:

sudo apt-get install zlib1g zlib1g-dev libedit2 libedit-dev llvm-3.6 llvm-3.6-dev llvm-dev
pip install enum34 funcsigs
LLVM_CONFIG=/usr/bin/llvm-config-3.6 pip install llvmlite
LLVM_CONFIG=/usr/bin/llvm-config-3.6 pip install numba
1

Initially I didn't get it working with the comments here and then I found out: 1. meanwhile llvm 3.6 instead of 3.5 is needed and 2. for me the LLVM_CONFIG env variable doesn't work. So I installed numba like this:

sudo apt-get install zlib1g zlib1g-dev libedit-dev llvm-3.6 llvm-3.6-dev llvm-3.6-runtime llvm-3.6-tools
sudo pip install enum34 funcsigs
sudo mv /usr/bin/llvm-config /usr/bin/llvm-config_bak
sudo ln -s /usr/bin/llvm-config-3.6 /usr/bin/llvm-config
sudo pip install llvmlite
sudo pip install numba
sudo mv /usr/bin/llvm-config_bak /usr/bin/llvm-config

(Tried on Ubuntu 14.04.)

Frank Zalkow
  • 3,850
  • 1
  • 22
  • 23
  • Unfortunately it does not work for me. In all cases when I try to install `llvmlite` by `pip` it fails with `error: option --single-version-externally-managed not recognized`. Any idea? I have been trying to install `numba` for the past 4 hours unsuccessfully so far. – maurizio Jun 02 '16 at 03:42
1

For Fedora 23

First check that you have the latest pip version:

pip install -U pip
pip install -U wheel

Then install the following pacakges:

dnf install zlib zlib-devel libstdc++-devel libstdc++ libstdc++-static llvm-3.7.0 llvm-devel-3.7.0 libedit libedit-devel
pip install enum34 funcsigs

Then download and unzip llvmlite from the GIT repository. Suppose that you are downloading to /usr/local/llvmlite then:

git clone <address-for-llvmlite.git> /usr/local/llvmlite
cd /usr/local/llvmlite

Build source as described here:

LLVM_CONFIG=/usr/bin/llvm-config python setupy.py build

Refresh terminal session and install built llvmlite

reset
LLVM_CONFIG=/usr/bin/llvm-config python setup.py install

Finally download and install numba by

pip install numba    
maurizio
  • 745
  • 1
  • 7
  • 25
0

For Ubuntu 16.04:

LLVM_CONFIG=/usr/bin/llvm-config-3.7 pip install llvmlite
fccoelho
  • 6,012
  • 10
  • 55
  • 67
0

For Ubuntu 16.04

sudo pip3 install llvmlite

explicitly requests llvm version 3.9.

But in the official packages, there is (currently) only llvm up to version 3.8. The solution is to install it like this

Then you can run LLVM_CONFIG=/usr/bin/llvm-config-3.9 sudo pip3 install llvmlite

Community
  • 1
  • 1
lhk
  • 27,458
  • 30
  • 122
  • 201
0

In case anyone else recently had this problem, according to their github page...

"llvmlite works with Python 2.7 and Python 3.4 or greater. As of version 0.17.0, llvmlite requires LLVM 4.0. It does not support earlier or later versions of LLVM.

They have a compatibility table of what works with what. All recent packages can be gotten from their webpage.

0

For Ubuntu 14.04 I managed to install with this:

export LDFLAGS="-std=gnu++11 -fPIC"

LLVM_CONFIG=/usr/bin/llvm-config-7 pip install llvmlite

LLVM_CONFIG=/usr/bin/llvm-config-7 pip install numba
CesarO
  • 1