Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

PyCUDA error: cannot import name intern

📅 2015-Feb-24 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

Problem

Running a simple PyCUDA program, I got this error:

$ python hello_cuda.py 
Traceback (most recent call last):
  File "hello_cuda.py", line 5, in <module>
    from pycuda.compiler import SourceModule
  File "/usr/local/lib/python2.7/dist-packages/pycuda/compiler.py", line 1, in <module>
    from pytools import memoize
  File "/usr/local/lib/python2.7/dist-packages/pytools/__init__.py", line 5, in <module>
    from six.moves import range, zip, intern, input
ImportError: cannot import name intern

Solution

The error had nothing to do with PyCUDA or CUDA, but with the six module which helps with compatibility between Python2 and Python3 code. It needed an upgrade and it worked after this:

$ sudo pip install six --upgrade

Tried with: Six 1.9.0, PyCUDA 2014.1, CUDA 5.5 and Ubuntu 14.04