I am on Fedora 38 linux and I have systemide installations of matplotlib (python3-matplotlib). However, I can not seem to be able to find it using reticulate. I tried:
library(reticulate)
mp <- import("matplotlib")
Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'matplotlib'
Error in py_module_import(module, convert = convert) :
ModuleNotFoundError: No module named 'matplotlib'
Run `reticulate::py_last_error()` for details.
> reticulate::py_last_error()
── Python Exception Message ────────────────────────────────────────────────────
Traceback (most recent call last):
File "/usr/lib64/R/library/reticulate/python/rpytools/loader.py", line 119, in _find_and_load_hook
return _run_hook(name, _hook)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/R/library/reticulate/python/rpytools/loader.py", line 93, in _run_hook
module = hook()
^^^^^^
File "/usr/lib64/R/library/reticulate/python/rpytools/loader.py", line 117, in _hook
return _find_and_load(name, import_)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'matplotlib'
── R Traceback ─────────────────────────────────────────────────────────────────
▆
1. └─reticulate::import("matplotlib")
2. └─reticulate:::py_module_import(module, convert = convert)
What am I doing wrong?
Sys.which("python")
python
"$HOME/.virtualenvs/r-reticulate/bin/python"
which leads to: python3.11
Note that I do not have a problem with importing sys:
main <- import_main()
sys <- import("sys")
Then
names(sys$modules)
[1] "sys" "builtins"
[3] "_frozen_importlib" "_imp"
[5] "_thread" "_warnings"
[7] "_weakref" "_io"
[9] "marshal" "posix"
[11] "_frozen_importlib_external" "time"
[13] "zipimport" "_codecs"
[15] "codecs" "encodings.aliases"
[17] "encodings" "encodings.utf_8"
[19] "_signal" "_abc"
[21] "abc" "io"
[23] "__main__" "_stat"
[25] "stat" "_collections_abc"
[27] "genericpath" "posixpath"
[29] "os.path" "os"
[31] "_sitebuiltins" "_distutils_hack"
[33] "types" "importlib._bootstrap"
[35] "importlib._bootstrap_external" "warnings"
[37] "importlib" "importlib._abc"
[39] "itertools" "keyword"
[41] "_operator" "operator"
[43] "reprlib" "_collections"
[45] "collections" "_functools"
[47] "functools" "contextlib"
[49] "importlib.util" "importlib.machinery"
[51] "google" "google.logging"
[53] "site" "enum"
[55] "numpy._globals" "numpy.__config__"
[57] "numpy._distributor_init" "__future__"
[59] "_sre" "re._constants"
[61] "re._parser" "re._casefix"
[63] "re._compiler" "copyreg"
[65] "re" "_json"
[67] "json.scanner" "json.decoder"
[69] "json.encoder" "json"
[71] "numpy._version" "numpy.version"
[73] "math" "_datetime"
[75] "datetime" "numpy.core._multiarray_umath"
[77] "numpy.compat._inspect" "fnmatch"
[79] "ntpath" "errno"
[81] "urllib" "ipaddress"
[83] "urllib.parse" "pathlib"
[85] "_struct" "struct"
[87] "_compat_pickle" "_pickle"
[89] "pickle" "numpy.compat.py3k"
[91] "numpy.compat" "numpy.core.overrides"
[93] "numpy.core.multiarray" "numpy.core.umath"
[95] "numbers" "numpy.core._string_helpers"
[97] "numpy.core._dtype" "numpy.core._type_aliases"
[99] "numpy.core.numerictypes" "numpy.core._exceptions"
[101] "collections.abc" "_contextvars"
[103] "contextvars" "numpy.core._ufunc_config"
[105] "numpy.core._methods" "numpy.core.fromnumeric"
[107] "numpy.core.shape_base" "numpy.core.arrayprint"
[109] "numpy.core._asarray" "numpy.core.numeric"
[111] "numpy.core.defchararray" "numpy.core.records"
[113] "numpy.core.memmap" "numpy.core.function_base"
[115] "numpy.core._machar" "numpy.core.getlimits"
[117] "numpy.core.einsumfunc" "numpy.core._multiarray_tests"
[119] "numpy.core._add_newdocs" "numpy.core._add_newdocs_scalars"
[121] "numpy.core._dtype_ctypes" "_ast"
[123] "ast" "_ctypes"
[125] "ctypes._endian" "ctypes"
[127] "numpy.core._internal" "numpy._pytesttester"
[129] "numpy.core" "numpy.lib.mixins"
[131] "numpy.lib.ufunclike" "numpy.lib.type_check"
[133] "numpy.lib.scimath" "numpy.lib.stride_tricks"
[135] "numpy.lib.twodim_base" "numpy.linalg._umath_linalg"
[137] "numpy.linalg.linalg" "numpy.linalg"
[139] "numpy.matrixlib.defmatrix" "numpy.matrixlib"
[141] "numpy.lib.histograms" "numpy.lib.function_base"
[143] "numpy.lib.index_tricks" "numpy.lib.nanfunctions"
[145] "numpy.lib.shape_base" "numpy.lib.polynomial"
[147] "textwrap" "numpy.lib.utils"
[149] "numpy.lib.arraysetops" "_weakrefset"
[151] "weakref" "numpy.lib.format"
[153] "numpy.lib._datasource" "numpy.lib._iotools"
[155] "numpy.lib.npyio" "numpy.lib.arrayterator"
[157] "numpy.lib.arraypad" "numpy.lib._version"
[159] "numpy.lib" "numpy.fft._pocketfft_internal"
[161] "numpy.fft._pocketfft" "numpy.fft.helper"
[163] "numpy.fft" "numpy.polynomial.polyutils"
[165] "numpy.polynomial._polybase" "numpy.polynomial.polynomial"
[167] "numpy.polynomial.chebyshev" "numpy.polynomial.legendre"
[169] "numpy.polynomial.hermite" "numpy.polynomial.hermite_e"
[171] "numpy.polynomial.laguerre" "numpy.polynomial"
[173] "cython_runtime" "_cython_0_29_34"
[175] "numpy.random._common" "binascii"
[177] "base64" "_hashlib"
[179] "_blake2" "hashlib"
[181] "hmac" "_bisect"
[183] "bisect" "_random"
[185] "_sha512" "random"
[187] "secrets" "threading"
[189] "numpy.random.bit_generator" "numpy.random._bounded_integers"
[191] "numpy.random._mt19937" "numpy.random.mtrand"
[193] "numpy.random._philox" "numpy.random._pcg64"
[195] "numpy.random._sfc64" "numpy.random._generator"
[197] "numpy.random._pickle" "numpy.random"
[199] "numpy.ctypeslib" "_opcode"
[201] "opcode" "dis"
[203] "token" "tokenize"
[205] "linecache" "inspect"
[207] "numpy.ma.core" "numpy.ma.extras"
[209] "numpy.ma" "numpy"
[211] "rpytools" "rpycall"
[213] "rpytools.call" "rpytools.loader"
[215] "signal" "rpytools.signals"
[217] "traceback"
There is no matplotlib here, but it is installed on my system: installed using sudo dnf install python3-matplotlib (version 3.7.3).
Thanks in advance for any helpful suggestions!