Numpy install with reticulate fail sanity check


I have a problem when installing numpy with reticulate.


In a new project, I install a new env:

python_version = "3.8.13"
reticulate::install_python(python_version) # Install python for the user, to be sure to be isolated
  envname = "penv/",
  version = python_version,
  packages = c("numpy == 1.22.4"),
  module = "venv",
  ignore_installed = TRUE,
  pip_options = "--upgrade --force-reinstall"

Then I open a python script and do import numpy.
Here is the result:

RuntimeError: The current Numpy installation ('/**my_home**/projects/22_06_Numpy_reprex/penv/lib/python3.8/site-packages/numpy/') fails to pass simple sanity checks. 
This can be caused for example by incorrect BLAS library being linked in, or by mixing package managers (pip, conda, apt, ...). Search closed numpy issues for similar problems.

My config:

I'm on a Centos 7.9.2009, Rstudio 2021.09.0 Build 351.pro6, R 4.0.5

py_config() result:

python:         /**my_home**/projects/22_06_Numpy_reprex/penv/bin/python
libpython:      /**my_home**/.pyenv/versions/3.8.13/lib/
pythonhome:     /**my_home**/projects/22_06_Numpy_reprex/penv:/**my_home**/projects/22_06_Numpy_reprex/penv
version:        3.8.13 (default, Jun 15 2022, 09:43:56)  [GCC 7.5.0]
numpy:          /**my_home**/projects/22_06_Numpy_reprex/penv/lib/python3.8/site-packages/numpy
numpy_version:  1.22.4

NOTE: Python version was forced by RETICULATE_PYTHON

The packages lapack and blas are installed on the server:

lapack.x86_64                      3.4.2-8.el7                         @base    
lapack-devel.x86_64                3.4.2-8.el7                         @base 
blas.x86_64                        3.4.2-8.el7                         @base    
blas-devel.x86_64                  3.4.2-8.el7                         @base    
openblas.x86_64                    0.3.3-2.el7                         @epel    
openblas-devel.x86_64              0.3.3-2.el7                         @epel    
openblas-openmp.x86_64             0.3.3-2.el7                         @epel    
openblas-openmp64.x86_64           0.3.3-2.el7                         @epel    
openblas-openmp64_.x86_64          0.3.3-2.el7                         @epel    
openblas-serial.x86_64             0.3.3-2.el7                         @epel    
openblas-serial64.x86_64           0.3.3-2.el7                         @epel    
openblas-serial64_.x86_64          0.3.3-2.el7                         @epel    
openblas-threads.x86_64            0.3.3-2.el7                         @epel    
openblas-threads64.x86_64          0.3.3-2.el7                         @epel    
openblas-threads64_.x86_64         0.3.3-2.el7                         @epel

I'm a little lost, everything I find on internet concern numpy 1.19.3 that had a problem, but it has been solved since, so I don't really know what to do. Maybe there is something wrong with my config ?

I tried to remove blas and lapack (leaving only openblas which is a dependency for my R install) and the problem is still the same.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

You can ensure that NumPy is linking to the same BLAS as R by building NumPy from source:

    "numpy", envname = envname, pip = TRUE,
    pip_options = c("--force-reinstall", "--no-binary numpy"))

If you're still encountering this problem, please file an issue on github using R 4.1.2 reticulate virtualenv will not allow numpy to pass sanity check · Issue #1257 · rstudio/reticulate · GitHub

1 Like