I run RStudio and reticulate (latest versions) on a windows 10 machine
When I step through my .Rmd file by running one chunk at a time, and I run a Python chunk that creates a hist of a series that contains categorical data, I get the bar chart, but after that all the output of subsequent Python chunks gets truncated: I get exactly one line of output (in a R Console panel) after each Python chunk.
The same happens if I “Run all” chunks
If I knit exactly the same .Rmd file, all the output (the histogram and the output of subsequent Python chunks) gets produced normally.
If I comment out that particular histogram chunk, then stepping through the .Rmd file by running one chunk at a time or by running all chunks also works fine.
library(knitr)
library(reticulate)
use_condaenv("r-reticulate")
print("\n start with import_python_packages")
from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedShuffleSplit
import os
print("print (done import os) do os.getcwd()")
print(os.getcwd() )
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:/Users/userXYZ/AppData/Local/r-miniconda/envs/r-reticulate/Library/plugins/platforms'
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
print("\n done with import_python_packages")
print(os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'])
A bunch of Python and R chunks that work fine.
housing["median_income_cat"]=pd.cut(housing["median_income"],
bins=[0., 1.5, 3.0, 4.5, 6., np.inf],
labels=[1, 2, 3, 4, 5])
temp_cat=housing["median_income_cat"]
print("type(temp_cat)",type(temp_cat), "\n")
type(temp_cat) <class 'pandas.core.series.Series'>
{python median_income_cat_histogram}
temp_cat.hist(figsize=(20,15), color="blue")
# # save_fig("attribute_histogram_plots_median_income_blue")
plt.show()
Run this Python chunk and get a bar chart of the temp_cat
After that every Python chunk that I run that is supposed to print output prints exactly one line of output (and puts it into an R console box, rather than simply in the output field.
If I run exactly the same .Rmd through knit, the output looks fine.
It is possible that this problem is related to this issue: maptlotlib plot causes knitting of .Rmd to get stuck