为 python 安装 numba
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14585598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing numba for python
提问by mijc
I am trying to install numbafor python but after following the instruction from the homepage I got this error that the extension_types page can not be found.
我正在尝试为 python安装numba,但是在按照主页的说明进行操作后,我收到了无法找到 extension_types 页面的错误。
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:
编辑:我通过以下方式安装了numba:
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 安装它时,出现以下错误:
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
回答by Mike Müller
Make a new virtual environment with virtualenvand install all needed components in the order given in the install instructions in this environment.
使用virtualenv 创建一个新的虚拟环境,并按照此环境中安装说明中给出的顺序安装所有需要的组件。
回答by kichik
I had the same issue and for me the solution was upgrading distributeto 0.6.45.
我遇到了同样的问题,对我来说,解决方案是将分发升级到 0.6.45。
回答by CompEcon
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. :)
我看到这个问题有点老了,但我会把我的经验放在这里,以防它帮助其他人使用谷歌搜索。对我来说,最简单的解决方案是安装 Anaconda 发行版:https: //store.continuum.io/请注意,有一个“非常免费”的通用版本,还有一个不错的学术版本……嗯,学术用途。:)
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 blogI'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.
Numba 实际上得到了 Continuum 人员的支持,至少根据他们的一个教程。我已经安装了它,现在才开始玩这个东西。到目前为止,我一直喜欢它(尽管在让它与我之前创建的一些 Cython 模块配合使用时遇到了一些小问题)。如果你走 Continuum 路线,他们有一个有点隐藏的博客,我发现它很有用(主页上的链接在“公司”下,这不是我第一次看到的地方)。查看他们标记为“Numba”的东西;那里有例子。
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.
我通过 Anaconda 使用 Numba 的另一个秘密原因:因为它们似乎相对较新,我推测它们可能非常“在”解决 Qs 或让 Numba 在他们的发行版中为您工作的问题——想要建立一个好名字和产品等等。当然,这只是我的纯粹猜测。
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 :)
唯一的缺点:Anaconda 中没有包含 Picloud。我过去经常使用它,所以这令人失望。这只是对我自己意味着更多的工作,但零工作很好:)
Note: I'm not affiliated with Continuum at all. I'm just pleasantly surprised with their product thus far.
注意:我根本不隶属于 Continuum。到目前为止,我对他们的产品感到惊喜。
回答by Suman Khanal
I hope you are on Linux and you have pip installed. On my Debian Linux, I can easily install numba by following commands:
我希望你使用的是 Linux 并且你已经安装了 pip。在我的 Debian Linux 上,我可以通过以下命令轻松安装 numba:
sudo apt-get install build-essential
sudo apt-get install llvm
pip install llvmpy
pip install cython
pip install numba
Then you are done!
然后你就完成了!
回答by user3683570
Working on windows I add the same problem i install Minicondaperform
在 Windows 上工作我添加了与安装Miniconda执行相同的问题
conda install numba
This install a python interpreter with all the numba's packages I then copied this packages to my interpreter's env
这将安装一个带有所有 numba 包的 python 解释器,然后我将这些包复制到我的解释器的 env
And your done
你完成了
回答by de_billa_
Following line of code solved my problem.
以下代码行解决了我的问题。
python -m pip install --user numba
This is for ubuntu.
这是针对 ubuntu 的。
回答by Atefeh Rashidi
I had same problem and I fixed it just by importing pandas before importing quantecon in my code:
我遇到了同样的问题,我只是通过在我的代码中导入 quantecon 之前导入 pandas 来修复它:
import pandas as pd
import quantecon as qe
It works for me.
这个对我有用。

