问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/45355711/dsx-python-import-error-undefined-symbol-pyunicodeucs2-asutf8string