Reputation: 976
I am a python beginner and I would like some help with this. I am using Ubuntu and I had installed python using Anaconda, but then I tried to install it again using pip and now when I'm trying to run my code, at import numpy as np
, I see this error
ImportError: /home/dev/.local/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: _PyUnicodeUCS4_IsWhitespace
How can I fix this?
Upvotes: 1
Views: 3833
Reputation: 68180
I also got this error. If you google for it, you will find lot's of similar issues. The problem can happen when you have multiple Python versions. In my case, I had the Ubuntu 16.04 Python 2.7 via /usr/bin/python
and another Python 2.7 via Linuxbrew. type python
gave me /u/zeyer/.linuxbrew/bin/python2
, i.e. the Linuxbrew one. type pip2.7
gave me /u/zeyer/.local/bin/pip2.7
, and looking into that file, it had the shebang #!/usr/bin/python
, i.e. it was using the Ubuntu Python.
So, there are various solutions. You could just edit the pip2.7
file and change the shebang to #!/usr/bin/env python2.7
. Or reinstall pip in some way.
In my case, I found that the Python 2.7 via Linuxbrew was incompatible to a few packages I needed (e.g. Tensorflow), so I unlinked it and use only the Ubuntu 16.04 Python 2.7 now.
Upvotes: 1
Reputation: 5704
Just uninstall numpy:
pip uninstall numpy
And reinstall numpy:
pip install numpy
Another thing you can do is run it on a virtual environment:
virtualenv myproject
cd myproject
source bin/activate
pip install numpy
Upvotes: 0