python + pycuda(linux)错误

时间:2014-12-18 15:24:08

标签: python pycuda

我通过以下链接安装了python + pycuda(以及其他库):http://wiki.tiker.net/PyCuda/Installation/Linux

但是当我运行测试程序时,它说:

Traceback (most recent call last):
File "test_driver.py", line 17, in <module>
import pycuda.gpuarray as gpuarray
File "/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.py", line 3, in <module>
import pycuda.elementwise as elementwise
File "/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/elementwise.py", line 34, in <module>
from pytools import memoize_method
File "/usr/local/lib/python2.7/dist-packages/pytools-2014.3.5-py2.7.egg/pytools/__init__.py", line 5, in <module>
from six.moves import range, zip, intern, input
ImportError: cannot import name intern
  • 安装了六个。我不知道该怎么做!

3 个答案:

答案 0 :(得分:3)

我在Ubuntu 14.04上看到了同样的问题,但是由于很多挑剔的依赖问题,我们不想覆盖Ubuntu的六个版本。我认为错误消息( 2014.3.5 )中的pytools版本与Ubuntu apt repo (2013.5.7)中的版本不匹配是奇怪的。

事实证明我以前曾尝试通过检查git存储库来从源代码安装pycuda。我以前也安装过pip。由于pytools在pycuda的setup.py中被列为要求,因此pip安装了pytools版本(2014.3.5)。这就是六和pytools之间不相容的地方。

为了解决这个问题,我使用pip remove pycuda pytools卸载了pycuda和pytools,然后使用apt-get安装了pycuda,然后自动安装了pytools的兼容版本。

只是想将此作为替代解决方案发布,以防其他人更喜欢保留默认的Ubuntu版本为6。

答案 1 :(得分:2)

在OSX系统上,我设法通过pip升级六个包来解决问题。亦即 $ pip install six --upgrade

答案 2 :(得分:0)

我在Ubuntu 14.04上遇到了同样的错误,但上面的提示都没有奏效。 This page建议直接编辑导致错误的文件。所以我编辑了/usr/local/lib/python2.7/dist-packages/pytools/__init__.py并更改了行:

from six.moves import range, zip, intern, input

try:
    from six.moves import range, zip, intern, input
except ImportError:
    from six.moves import range, zip, input

编辑包含的库文件并不是很好,但它解决了错误。