Sven Hafeneger
Sven Hafeneger

Reputation: 801

DSX Python import error : undefined symbol: PyUnicodeUCS2_AsUTF8String

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.

Upvotes: 3

Views: 990

Answers (1)

Sumit Goyal
Sumit Goyal

Reputation: 575

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.

Upvotes: 4

Related Questions