Saeed
Saeed

Reputation: 141

python+ pycuda (linux) error

I've installed python+pycuda (and other libraries) through this link: http://wiki.tiker.net/PyCuda/Installation/Linux

But when I run test program, it says:

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

Upvotes: 2

Views: 1981

Answers (3)

Paul
Paul

Reputation: 699

I had the same error on Ubuntu 14.04 but neither of the tips above worked. This page recommends editing the file causing the error directly. So I edited /usr/local/lib/python2.7/dist-packages/pytools/__init__.py and changed the line:

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

Into

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

Not nice editing included library files, but it got around the error.

Upvotes: 0

Fiver
Fiver

Reputation: 10167

I was seeing this exact same issue on Ubuntu 14.04 but didn't want to override Ubuntu's version of six due to lots of finicky dependency issues. I thought it was odd that the pytools version in the error message (2014.3.5) didn't match the version from the Ubuntu apt repo (2013.5.7).

It turns out that I had previously tried to install pycuda from source by checking out the git repository. I had also previously installed pip. Since pytools is listed as a requirement in pycuda's setup.py, pip installed its version of pytools (2014.3.5). And that's where the incompatibility between six and pytools originates.

To solve the issue, I uninstalled both pycuda and pytools using pip remove pycuda pytools and then installed pycuda using apt-get which then auto-installed the compatible version of pytools.

Just wanted to post this as an alternative solution in case anyone else prefers to keep the default Ubuntu version of six.

Upvotes: 3

Nobuo Sato
Nobuo Sato

Reputation: 36

On a OSX system I manage to solve the problem by upgrading the six package via pip. Namely $ pip install six --upgrade

Upvotes: 2

Related Questions