Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUMPY NOT FOUND BUT ACTUALLY INSTALLED #1593

Open
ericpeny opened this issue Apr 19, 2024 · 7 comments
Open

NUMPY NOT FOUND BUT ACTUALLY INSTALLED #1593

ericpeny opened this issue Apr 19, 2024 · 7 comments

Comments

@ericpeny
Copy link

ericpeny commented Apr 19, 2024

I have conda installed on the server, created an environment, installed all packages needed.
I checked conda, python, library as following.

(trialbot) bash-4.2$ which conda
~/miniconda3/bin/conda
(trialbot) bash-4.2$ which python
~/miniconda3/envs/trialbot/bin/python
(trialbot) bash-4.2$ python
Python 3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.26.4'

In Rstudio, I setup env variable in .Renviron as

RETICULATE_PYTHON=~/miniconda3/envs/trialbot/bin/python3.10
I set python interpreter using ~/miniconda3/envs/trialbot/bin/python
I set all the configure as many as possible
Sys.setenv(RETICULATE_PYTHON = "~/miniconda3/envs/trialbot/bin/python")
use_python("~/miniconda3/envs/trialbot/bin/python")

But NUMPY NOT FOUND!

py_config()
python: /home/e0564278/miniconda3/envs/trialbot/bin/python
libpython: /home/e0564278/miniconda3/envs/trialbot/lib/libpython3.10.so
pythonhome: /home/e0564278/miniconda3/envs/trialbot:/home/e0564278/miniconda3/envs/trialbot
version: 3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0]
numpy: [NOT FOUND]

NOTE: Python version was forced by RETICULATE_PYTHON

And I even forced it to install, but no help.
reticulate::py_install(envname = "~/miniconda3/envs/trialbot", python_version = '3.10.14',
packages = "numpy", pip = TRUE, pip_ignore_installed = TRUE)

What can I do?

@t-kalinowski
Copy link
Member

My best guess is that this is a different manifestation of a binary incompatibility between the R build and the Conda built NumPy.

Do you see the same error if you use a virtualenv?

@ericpeny
Copy link
Author

My best guess is that this is a different manifestation of a binary incompatibility between the R build and the Conda built NumPy.

Do you see the same error if you use a virtualenv?

Thank you for your quick reply! I tried to create a virtualenv, and use it in RSTUDIO, and still get numpy not found. If the incompatibility exisits, how can I solve it?

@t-kalinowski
Copy link
Member

What is the output from running this?

library(reticulate)
install_python("3.10:latest")
virtualenv_create(force = TRUE, version = "3.10")
.rs.restartR() # restart R manually if outside RStudio

reticulate::py_config()

@ericpeny
Copy link
Author

ericpeny commented Apr 19, 2024

What is the output from running this?

library(reticulate)
install_python("3.10:latest")
virtualenv_create(force = TRUE, version = "3.10")
.rs.restartR() # restart R manually if outside RStudio

reticulate::py_config()

I always have this system python path numpy loaded.

@t-kalinowski
Copy link
Member

Do you know how the other Numpy is getting placed on sys.path?

Is PYTHONPATH defined?

Sys.getenv("PYTHONPATH")

Perhaps some other mechanism?

@t-kalinowski
Copy link
Member

t-kalinowski commented Apr 19, 2024

It might make sense for us to invoke pip with the -I flag: https://docs.python.org/3/using/cmdline.html#cmdoption-I

@ericpeny
Copy link
Author

Do you know how the other Numpy is getting placed on sys.path?

Is PYTHONPATH defined?

Sys.getenv("PYTHONPATH")

Perhaps some other mechanism?

Thank you! I reset my PYTHONPATH, removed the system python library, then it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants