piwheels / packages

Issue tracker for piwheels package issues
https://github.com/piwheels/packages/issues
20 stars 5 forks source link

numpy wheel not working on Pi Zero W (armv6l) #201

Closed tszolar closed 3 years ago

tszolar commented 3 years ago

Package name: numpy Link to PyPI page: https://pypi.org/project/numpy Link to piwheels page: https://www.piwheels.org/project/numpy Version: 1.20.2 Python version: 3.7.10 I am the maintainer: No More information:

When numpy is installed from piwheels on Raspberry Pi Zero W, import numpy as np fails with error ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'. In the error message there is no mention of any missing so library, just the generic Importing the numpy C-extensions failed..

Packages libatlas-base-dev libatlas3-base libgfortran5 are installed. Correct wheel is installed (numpy-1.20.2-cp37-cp37m-linux_armv6l.whl).

I assume that is has to do something with the Pi Zero old CPU architecture (armv6l), because on RPi 3 (armv7l) the exact same setup works without problems.

Full error output - tested on buster with Python 3.7:

pi@pizerowh:~ $ docker run --rm -it python:3.7-buster bash
root@260c7138ed92:/# apt update && apt-get install libatlas-base-dev libatlas3-base libgfortran5
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main armel Packages [246 kB]
Get:5 http://deb.debian.org/debian buster/main armel Packages [7628 kB]
Get:6 http://deb.debian.org/debian buster-updates/main armel Packages [9504 B]                                                                                                                             
Fetched 8122 kB in 22s (372 kB/s)                                                                                                                                                                          
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libatlas-doc liblapack-doc
The following NEW packages will be installed:
  libatlas-base-dev libatlas3-base libgfortran5
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 8103 kB of archives.
After this operation, 45.8 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main armel libgfortran5 armel 8.3.0-6 [216 kB]
Get:2 http://deb.debian.org/debian buster/main armel libatlas3-base armel 3.10.3-8 [3969 kB]
Get:3 http://deb.debian.org/debian buster/main armel libatlas-base-dev armel 3.10.3-8 [3918 kB]
Fetched 8103 kB in 5s (1575 kB/s)            
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libgfortran5:armel.
(Reading database ... 24343 files and directories currently installed.)
Preparing to unpack .../libgfortran5_8.3.0-6_armel.deb ...
Unpacking libgfortran5:armel (8.3.0-6) ...
Selecting previously unselected package libatlas3-base:armel.
Preparing to unpack .../libatlas3-base_3.10.3-8_armel.deb ...
Unpacking libatlas3-base:armel (3.10.3-8) ...
Selecting previously unselected package libatlas-base-dev:armel.
Preparing to unpack .../libatlas-base-dev_3.10.3-8_armel.deb ...
Unpacking libatlas-base-dev:armel (3.10.3-8) ...
Setting up libgfortran5:armel (8.3.0-6) ...
Setting up libatlas3-base:armel (3.10.3-8) ...
update-alternatives: using /usr/lib/arm-linux-gnueabi/atlas/libblas.so.3 to provide /usr/lib/arm-linux-gnueabi/libblas.so.3 (libblas.so.3-arm-linux-gnueabi) in auto mode
update-alternatives: using /usr/lib/arm-linux-gnueabi/atlas/liblapack.so.3 to provide /usr/lib/arm-linux-gnueabi/liblapack.so.3 (liblapack.so.3-arm-linux-gnueabi) in auto mode
Setting up libatlas-base-dev:armel (3.10.3-8) ...
update-alternatives: using /usr/lib/arm-linux-gnueabi/atlas/libblas.so to provide /usr/lib/arm-linux-gnueabi/libblas.so (libblas.so-arm-linux-gnueabi) in auto mode
update-alternatives: using /usr/lib/arm-linux-gnueabi/atlas/liblapack.so to provide /usr/lib/arm-linux-gnueabi/liblapack.so (liblapack.so-arm-linux-gnueabi) in auto mode
Processing triggers for libc-bin (2.28-10) ...
root@260c7138ed92:/# pip3 --no-cache-dir install --user --extra-index-url https://www.piwheels.org/simple numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting numpy
  Downloading https://www.piwheels.org/simple/numpy/numpy-1.20.2-cp37-cp37m-linux_armv6l.whl (11.6 MB)
     |████████████████████████████████| 11.6 MB 884 kB/s 
Installing collected packages: numpy
  WARNING: The scripts f2py, f2py3 and f2py3.7 are installed in '/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.20.2
root@260c7138ed92:/# python3
Python 3.7.10 (default, Apr 10 2021, 09:47:19) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/root/.local/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/root/.local/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/.local/lib/python3.7/site-packages/numpy/__init__.py", line 145, in <module>
    from . import core
  File "/root/.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 "/usr/local/bin/python3"
  * The NumPy version is: "1.20.2"

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

Original error was: No module named 'numpy.core._multiarray_umath'
rpomykala commented 3 years ago

Can confirm this issue here as well

bennuttall commented 3 years ago

I've tested this many times and never managed to reproduce it.

However, looking at @flexik's Docker build output, I see:

Get:1 http://deb.debian.org/debian buster/main armel libgfortran5 armel 8.3.0-6 [216 kB]
Get:2 http://deb.debian.org/debian buster/main armel libatlas3-base armel 3.10.3-8 [3969 kB]
Get:3 http://deb.debian.org/debian buster/main armel libatlas-base-dev armel 3.10.3-8 [3918 kB]

This is targetting the armel Debian repo, not the armhf one. See https://www.debian.org/ports/arm/

The wheels are built against the armhf repos provided by Raspberry Pi. You need to install the apt packages from an armhf repo.

yaakov-h commented 3 years ago

According to the Debian documentation the Pi Zero W uses armel, not armhf.

If you need a repro case, the radiosonde_auto_rx docker image exhibits the problem reliably when run on a Pi Zero W.

bennuttall commented 3 years ago

No, that's not true. It's possible to use either armhf or armel Debian on Pi 1/Zero but piwheels builds wheels on Raspberry Pi OS which is armhf, so you have to use armhf if you want the wheels to work.