Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

PyCUDA error: cannot import name intern

📅 2015-Feb-24 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ error, pycuda, six ⬩ 📚 Archive


Running a simple PyCUDA program, I got this error:

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


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

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧