'Cannot install Scipy in FreeBSD 13 with Python 3.10

I am trying install scipy in FreeBSD 13. I have built python 3.10 on FreebSD 13 and managed to install pandas, matplotlib and numpy on a virtual environment which has python 3.10. However, when I try to install sklearn or scipy I get an error saying scipy could not be installed. Here it is below for when doing pip install scipy. I get the same error more or less when trying to install sklearn.

ERROR: Failed building wheel for scipy
  Failed to build scipy
  ERROR: Could not build wheels for scipy, which is required to install pyproject.toml-based projects
Command errored out with exit status 1: /home/schroter/.pymain/dataViz/bin/python3 /tmp/pip-standalone-pip-d3nnvp2f/__env_pip__.zip/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-xp_669rf/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.28.5' 'oldest-supported-numpy; python_version!='"'"'3.7'"'"' or platform_machine=='"'"'aarch64'"'"' or platform_system=='"'"'AIX'"'"' or platform_python_implementation == '"'"'PyPy'"'"'' 'numpy==1.14.6; python_version=='"'"'3.7'"'"' and platform_machine!='"'"'aarch64'"'"' and platform_system!='"'"'AIX'"'"' and platform_python_implementation != '"'"'PyPy'"'"'' 'scipy>=1.1.0' Check the logs for full command output.

My pip list is as below:

(dataViz) schroter@SCHROTER:~ % pip list
Package          Version
---------------- -------
cycler           0.11.0
kiwisolver       1.1.0
matplotlib       3.4.3
numpy            1.21.4
pandas           1.3.4
Pillow           8.4.0
pip              21.3.1
pyparsing        3.0.6
python-dateutil  2.8.2
pytz             2021.3
semantic-version 2.8.5
setuptools       58.5.3
setuptools-rust  0.12.1
six              1.16.0
toml             0.10.2
wheel            0.37.0

Would anyone be able to help me in this regards please? Thanks & Best Regards Schroter



Solution 1:[1]

Reuse system package

# install system-wide version in site-packages
doas pkg install py38-scipy-1.8.0
# create a virtualenv with site-packages included
python -m venv --system-site-packages .venv

Drawback is you'll get all packages from site-packages, however you can tackle that by

doas pkg install py38-scipy-1.8.0
python -m venv .venv

YOUR_PYTHON_VERSION= SET IT HERE
ln -s $(python -c 'import lxml, os.path; print(os.path.dirname(lxml.__file__)') ./.venv/lib/$YOUR_PYTHON_VERSION/site-packages

borrowed from https://stackoverflow.com/a/13719417

Regular Installation (TODO)

Haven't figured out it yet, but maybe someone else will, so putting here 2 links which might be helpful

  1. https://forums.freebsd.org/threads/python-scipy-with-python3-x-on-freebsd-11.59009/
  2. https://reviews.freebsd.org/D23447

Solution 2:[2]

Have you tried to install scipy from freebsd ports? The freebsd ports contain patches to make the code compile on FreeBSD.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 arved