Numpy install woes

Recently I’ve started a project to look at tracking stocks combined with  company sentiment – utilising Python running on a little Raspberry Pi. I’ll link to the detailed project posts at a later point.

Anyway the first hurdle I’ve hit was getting NumPy to install correctly with the usual pip install giving the following error when NumPy is called…

ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

—————————————-
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.7/dist-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpumibpogm Check the logs for full command output.

I tried a couple of things to fix this…

  1. Repeating the install and specifying the upgrade flag.
    sudo pip3 install -U numpy
    Note -U = –upgrade
  2. Uninstalling and re-installing NumPy and Setuptools.
    sudo pip3 uninstall -y numpy
    sudo pip3 uninstall -y setuptools
    sudo pip3 install -U setuptools
    sudo pip3 install -U numpy
    Note -y = –yes Don’t ask for confirmation of uninstall deletions.
  3. The uninstall of NumPy didn’t work so I moved to apt-get:-
    sudo apt-get remove python-numpy
    Which did the trick…

But to know avail.
So after a little light browsing I came up with an answer – not all of the NumPy dependencies had been installed. Ineed to run 

sudo apt-get install python-dev libatlas-base-dev

Which then allowed NumPy to be reinstalled and worked a treat.

Leave a Reply