Open dditomma opened 4 months ago
I suspect (but haven't tested) this is a CentOS 7 issue, with the system BLAS version installed being too old for the latest NumPy.
Does rolling back NumPy fix the issue?
py_install("numpy<2")
If that doesn't work, would you be able to reduce this down to a minimal example I could reproduce locally?
i.e.,
library(reticulate)
virtualenv_create(force = TRUE, version = "3.9")
np_array(1:3)
which for me gives:
....
Successfully installed numpy-2.0.0
Virtual environment '~/.virtualenvs/r-reticulate' successfully created.
#> np_array(1:3)
array([1, 2, 3], dtype=int32)
Thanks for taking a look, Tomasz! Your compact example demonstrates a problem on my end. All is well until the np_array()
call, which fails on a core.multiarray error, at bottom:
Same diagnostics as before attached as r-session-fail.log.
...
Installing packages: numpy
+ ~/.virtualenvs/r-reticulate/bin/python -m pip install --upgrade --no-user numpy
Looking in indexes: https://rstudiopm.company.com/pypi/2022-10-04/simple
Collecting numpy
Downloading https://rstudiopm.company.com/pypi/date/packages/numpy/hash/numpy-1.23.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.1/17.1 MB 230.9 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.23.3
Virtual environment '~/.virtualenvs/r-reticulate' successfully created.
> np_array(1:3)
Error: Required version of NumPy not available: numpy.core.multiarray failed to import
I've put together a minimal Dockerfile starting from centos7, and installing R and Python. Everything seems to work fine. Would you be able to iterate on this Dockerfile until you can reproduce the error in it?
FROM centos:7
RUN `which sudo` yum install -y https://github.com/r-lib/rig/releases/download/latest/r-rig-latest-1.$(arch).rpm
RUN rig add release
RUN R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
RUN R -q -e 'pak::pkg_install("reticulate")'
RUN yum install -y git
RUN yum install -y gcc make patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel
RUN R -q -e 'reticulate::install_python("3.9")'
RUN R -q -e 'reticulate::virtualenv_create()'
RUN R -q -e 'reticulate::np_array(1:3)'
Run from bash with:
docker build -t reticulate-centos7 -f centos7.Dockerfile .
I don't find docker in my env ('which' finds no docker in path). I tried in the Docker Playground and the sessions spontaneously shut down just as they install_python() - the start of those last three RUN steps (screenshots, even though the playground session should not time out after a few minutes).
I'll report to our infrastructure team and see if they can track down the conflict.
Instead of building Python from source with reticulate::install_python()
, you can try installing pre-built binaries from https://github.com/rstudio/python-builds?tab=readme-ov-file#rhelcentos-linux
Is this issue back, reticulate virtualenv will not allow numpy to pass sanity checks?
Please note I have user access to my env, so ability to change most wiring is restricted.
py_install( ... "--force-reinstall" ...)
worked, as advised in the prior issue, but import then fails. The numpy sanity error is at the bottom:RuntimeError: The current Numpy installation ('/local-home/repos/project/.venv/lib/python3.9/site-packages/numpy/__init__.py') 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.
utils::sessionInfo()
RStudio.Version()
reticulate::py_config()
import error