rstudio / rstudio/reticulate

Rmarkdown: Error in py_module_import : No module named 'rpytools'

Open
#283 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.8k
Forks
349
Avg merge
5h 13m
Merged PRs (30d)
4

Description

Apologies this is a crosspost from stack overflow as I got no reply there.


I am trying to add a python chunk in a rmarkdown document. I installed package reticulate then here is my document:

```{r, message=FALSE, warning=FALSE, echo = FALSE}
  library(reticulate)
```

```{python, echo = FALSE, eval = FALSE}
a=1
a
#import numpy as np
#import matplotlib.pyplot as plt

## evenly sampled time at 200ms intervals
#t = np.arange(0., 5., 0.2)

## red dashes, blue squares and green triangles
#plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
#plt.show()
```

However I get this error when knitting the document: (note that the error happens when running the second chunk)

label: unnamed-chunk-1 (with options) 
List of 3
 $ message: logi FALSE
 $ warning: logi FALSE
 $ echo   : logi FALSE


  |                                                                       
  |....                                                             |   6%
  ordinary text without R code


  |                                                                       
  |......                                                           |   9%
label: unnamed-chunk-2 (with options) 
List of 3
 $ echo  : logi FALSE
 $ eval  : logi FALSE
 $ engine: chr "python"

Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'rpytools'
Calls: <Anonymous> ... remap_output_streams -> import -> py_module_import -> .Call

Also adding that I did not find any information on this on https://github.com/rstudio/reticulate
and
https://rstudio.github.io/reticulate/articles/r_markdown.html

I have knitr version 1.20, which is above 1.18 hence engine configuration should be automatic.

I also precise python3 is present in the windows PATH.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported R Markdown document with reticulate on Windows, focusing on the second {python} chunk and the py_module_import/remap_output_streams stack. Check the installed Python environment and reticulate/knitr versions against the documented R Markdown setup. Done when the chunk knits without the missing-module error or the required environment configuration is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, r
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.