3

On IBM DSX, I have a spark service instance on which I have installed a few newer versions of packages such as numpy.

I am facing an issue with the import of numpy. The following code:

import numpy

raises this error message:

ImportError: /gpfs/fs01/user/USERID/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS2_AsUTF8String

The import used to work.

Sven Hafeneger
  • 801
  • 6
  • 13

1 Answers1

4

This is because of a mismatch in the Unicode characters representation between Python that you are using and the package you are importing. Solution is to use the extension modules compiled with a Python binary built using the same size for Unicode characters. You can update the Python2 packages installed in IBM Data Science Expereince Notebooks by:

!pip freeze --user > requirements.txt
!while read p; do pip install --user "${p}" --ignore-installed ; done <./requirements.txt

Restart the notebook kernel as a precaution.

Sumit Goyal
  • 575
  • 3
  • 16