astro-pi/python-sense-hat

Numpy error running sense-hat module > python 2

moritzsalla opened this issue · 3 comments

Is it possible to run sense-hat on 3.7.0? If not, what is the highest python version it can run on?
I have tried 3.9.0, which also fails.

pi@raspberrypi:~ $ python
Python 3.7.0 (default, Oct 19 2020, 11:47:14) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sense_hat import SenseHat
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/sense_hat/__init__.py", line 2, in <module>
    from .sense_hat import SenseHat, SenseHat as AstroPi
  File "/home/pi/.local/lib/python3.7/site-packages/sense_hat/sense_hat.py", line 7, in <module>
    import numpy as np
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/home/pi/.local/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/home/pi/.pyenv/versions/3.7.0/bin/python"
  * The NumPy version is: "1.19.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

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

>>> 

Ok, I got it to work on Thonny running Python 3.7.3 (/usr/bin/python3). However, running my script in terminal using pyenv 3.9 (/home/pi/.pyenv/shims/python) gives me this error:

ModuleNotFoundError: No module named 'sense_hat'

I'm installing 3.7.3 on pyenv to see if that will run it.

Update: after installing 3.7.3 using pyenv and sense-hat using pip, I am getting the original numpy error.

After finding this page: https://www.raspberrypi.org/forums/viewtopic.php?t=154230, I followed all steps, but I'm still stuck with either the "missing module" or "Importing the numpy C-extensions failed" error.

I tried:

sudo apt-get remove python-sense-hat python3-sense-hat
sudo pip install sense_hat
sudo pip3 install sense_hat

and:

sudo apt-get update
sudo apt-get install python-sense-hat python3-sense-hat -y

furthermore:

sudo apt-get remove python-sense-hat python3-sense-hat
sudo -H pip install sense_hat
sudo -H pip3 install sense_hat

also:

git clone https://github.com/RPi-Distro/python-sense-hat
cd python-sense-hat
sudo python setup.py install
sudo python3 setup.py install

Thonny on Python 3.7.3 (/usr/bin/python3) works fine, but I need it working with pyenv in bash.

Your original numpy error said libf77blas.so.3 is missing. It can be installed by running:

 sudo apt install libatlas-base-dev