Open masonlr opened 5 years ago
Getting a comparable error in the context of a virtualenv with output: github_document
Having similar problems too but as stated above with a virtual environment trying to knit to a github doc. Please any suggestions would be very helpful.
Got the below error message:
Quitting from lines 51-65 (python2.rmd) Error in py_call_impl(callable, dots$args, dots$keywords) : RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
Detailed traceback:
File "
Just to add that this issue is not related specifically to conda environment. Using OSX system Python you get the same error.
It is enough to create a blank Rmd, to call in an R chunk
Sys.setenv(RETICULATE_PYTHON = '/Library/Frameworks/Python.framework/Versions/3.6/bin/python3')
and then add a python chunk
import matplotlib.pyplot as plt
to get a file that executes fine when run in RStudio and gives the same error reported by tosi-n:
Error in py_call_impl(callable, dots$args, dots$keywords) :
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework.
Importing just matplotlib does not trigger this error, but since RStudio can easily run such a chunk I would expect the knitr-engine shall be able to as well ;-)
https://github.com/matplotlib/matplotlib/blob/master/doc/users/prev_whats_new/whats_new_3.1.0.rst#matplotlib-no-longer-requires-framework-app-build-on-macosx-backend suggests that this is fixed in the newest versions of matplotlib.
Sorry for the late reply, but I can confirm that latest matplotlib fixes the issue I was experiencing with base Python 3.
I still find it weird that running chunks in RStudio was having no problem and knitr-engine was failing, but in the end I will just use it happily without further questions :-)
Does the reticulate knitr-engine support matplotlib figures when using
pdf_document
as an output format?Example
With the following minimal content (in R Markdown format),
the plot renders correctly inline when using "Run Selected Line(s)" in the RStudio editor. When using "Knit", however, I'm getting the following error:
Environment
The R package versions are:
The python environment was set up using:
The reticulate python environment variable was set using a local
.Rprofile
file using:Attempts to solve
reticulate::use_condaenv()
method via an.Rprofile
file using:RSTUDIO_WHICH_R=/Users/username/miniconda3/envs/test/bin/R
) installed via: