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

Could not import matplotlib.pyplot, - Nevergrad Issue #820

Open
Michaelmlewis opened this issue Sep 18, 2023 · 1 comment
Open

Could not import matplotlib.pyplot, - Nevergrad Issue #820

Michaelmlewis opened this issue Sep 18, 2023 · 1 comment
Assignees

Comments

@Michaelmlewis
Copy link

I am trying to install nevergrad via pip
using the following
library("reticulate") virtualenv_create("r-reticulate") use_virtualenv("r-reticulate", required = TRUE) Sys.setenv(RETICULATE_PYTHON = "C:/Users/MIAT40093/Documents/.virtualenvs/r-reticulate/Scripts/python.exe") py_install("numpy", pip = TRUE) py_install("nevergrad", pip = TRUE)

when I run py_module_available("nevergrad") I get the following error
C:\Users\MIAT401\DOCUME1\VIRTUA1\R-RETI1\Lib\site-packages\cma\s.py:13: UserWarning: Could not import matplotlib.pyplot, therefore cma.plot() etc. is not available
_warnings.warn('Could not import matplotlib.pyplot, therefore'
[1] FALSE

Here is my 'py_config() '
python: C:/Users/MIAT40093/Documents/.virtualenvs/r-reticulate/Scripts/python.exe
libpython: C:/Users/MIAT40093/AppData/Local/Programs/Python/Python311/python311.dll
pythonhome: C:/Users/MIAT40093/Documents/.virtualenvs/r-reticulate
version: 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/MIAT40093/Documents/.virtualenvs/r-reticulate/Lib/site-packages/numpy
numpy_version: 1.26.0

NOTE: Python version was forced by RETICULATE_PYTHON

I tried alot of the mentioned solutions, with no luck :(

Would you please advise

@gufengzhou
Copy link
Contributor

gufengzhou commented Sep 20, 2023

Very tricky issue :( reticulate often fails to pick up the right python config by default. Below is my py_config(), as you see I'm using the python libs installed by miniconda.

image

Maybe it's worth trying this out, in the documentation ?reticulate::install_python, you can see the "recommended" Python installation. Just to copy paste the content for easier reference here. I suggest NOT using the latest Python version because I remember reticulate having problems with the latest sometimes.

# In general, it is recommended that Python virtual environments are created using the copies of Python installed by  install_python(). For example:

library(reticulate)
version <- "3.9.12"
install_python(version)
virtualenv_create("my-environment", version = version)
use_virtualenv("my-environment")

# There is also support for a ":latest" suffix to select the latest patch release
install_python("3.9:latest") # install latest patch available at python.org

# select the latest 3.9.* patch installed locally
virtualenv_create("my-environment", version = "3.9:latest")
# Note
# On macOS and Linux this will build Python from sources, which may take a few minutes. Installation will be faster if some build dependencies are preinstalled. See https://github.com/pyenv/pyenv/wiki#suggested-build-environment for example commands you can run to pre-install system dependencies (requires administrator privileges). Python is built with PYTHON_CONFIGURE_OPTS=--enable-shared set.

# On Windows, prebuilt installers from https://www.python.org/ are used.

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