mijc
mijc

Reputation: 1189

Installing numba for python

I am trying to install numba for python but after following the instruction from the homepage I got this error that the extension_types page can not be found.

I would very appreciate if someone knows what I am doing wrong or if I missed something that I should install.

Thank you very much in advance.

Python 2.7.2+ (default, Jul 20 2012, 22:15:08) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import numba
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/home/mijc/Downloads/numba/<ipython console> in <module>()

/home/mijc/Downloads/numba/numba/__init__.py in <module>()
      2 # type inferer

      3 from numba.special import *
----> 4 from numba import module_type_inference
      5 
      6 import os

/home/mijc/Downloads/numba/numba/module_type_inference.py in <module>()
      6 from numba import *
      7 from numba.minivect import minitypes
----> 8 from numba import typesystem, symtab
      9 
     10 import numpy.random

/home/mijc/Downloads/numba/numba/typesystem/__init__.py in <module>()
      2 from exttypes import *
      3 from closuretypes import *
      4 from ssatypes import *
      5 from templatetypes import *
      6 from typemapper import *

/home/mijc/Downloads/numba/numba/typesystem/basetypes.py in <module>()
      6 
      7 import numba
----> 8 from numba import  extension_types, error
      9 from numba.minivect.minitypes import *
     10 from numba.minivect.minitypes import map_dtype

ImportError: cannot import name extension_types

EDIT: I installed numba via:

git clone https://github.com/numba/numba.git
cd numba
python setup.py install

When I try to install it via pip, I get the following error:

pip install numba --upgrade
Downloading/unpacking numba
  Downloading numba-0.5.0.tar.gz (333Kb): 333Kb downloaded
  Running setup.py egg_info for package numba
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/mijc/Downloads/numba/build/numba/setup.py", line 90, in <module>
        cython_gdb=True),
      File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/extension.py", line 108, in __init__
        **kw)
    TypeError: unbound method __init__() must be called with Extension instance as first argument (got Extension instance instead)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/home/mijc/Downloads/numba/build/numba/setup.py", line 90, in <module>

    cython_gdb=True),

  File "/usr/local/lib/python2.7/dist-packages/Cython/Distutils/extension.py", line 108, in __init__

    **kw)

TypeError: unbound method __init__() must be called with Extension instance as first argument (got Extension instance instead)

----------------------------------------
Command python setup.py egg_info failed with error code 1

Upvotes: 23

Views: 64230

Answers (9)

Neil Davis
Neil Davis

Reputation: 236

pip install numba

works on 3.12.3. Maybe some stuff has been ironed out?

Upvotes: -1

schmi
schmi

Reputation: 397

Try:

pip install numba==0.48

Looks like that the decorators module are removed in later numba versions.

Upvotes: 1

Atefeh Rashidi
Atefeh Rashidi

Reputation: 515

I had same problem and I fixed it just by importing pandas before importing quantecon in my code:

import pandas as pd
import quantecon as qe

It works for me.

Upvotes: -1

billa-code
billa-code

Reputation: 569

Following line of code solved my problem.

python -m pip install --user numba

This is for ubuntu.

Upvotes: 3

user3683570
user3683570

Reputation: 61

Working on windows I add the same problem i install Miniconda perform

conda install numba 

This install a python interpreter with all the numba's packages I then copied this packages to my interpreter's env

And your done

Upvotes: 6

Suman
Suman

Reputation: 3545

I hope you are on Linux and you have pip installed. On my Debian Linux, I can easily install numba by following commands:

sudo apt-get install build-essential
sudo apt-get install llvm
pip install llvmpy
pip install cython
pip install numba

Then you are done!

Upvotes: 12

CompEcon
CompEcon

Reputation: 2024

I see this question is a little old, but I'll put my experience here in case it helps others googling. The easiest solution for me was to install the Anaconda distribution: https://store.continuum.io/ Note there is a "very free" version for general use, and a nice academic version for ... well, academic use. :)

Numba is actually supported by the Continuum folks, at least according to one of their tutorials. I've installed it and am just now starting to play around with the thing. I've liked it thus far (although have had some minor trouble getting it to play nice with some Cython modules I previously created). If you go the Continuum route, they have a somewhat hidden blog I've found useful (the link on the main page is under "Company", which is not the first place I look). Check out their things tagged "Numba;" there are examples there.

My other secret reason for using Numba via Anaconda: since they seem to be relatively new, I speculate they may be very "on top of" addressing Qs or problems getting Numba working for you in their distrib -- wanting to build a good name and product and all that. This is, of course, just pure speculation on my part.

The only downside: no inclusion of Picloud in Anaconda. I have used that quite a bit in the past, so this is disappointing. It just means a little more work for myself, but zero work is nice :)

Note: I'm not affiliated with Continuum at all. I'm just pleasantly surprised with their product thus far.

Upvotes: 2

kichik
kichik

Reputation: 34744

I had the same issue and for me the solution was upgrading distribute to 0.6.45.

Upvotes: 5

Mike M&#252;ller
Mike M&#252;ller

Reputation: 85582

Make a new virtual environment with virtualenv and install all needed components in the order given in the install instructions in this environment.

Upvotes: -1

Related Questions