How can I specify rmarkdown to use python3 instead python 2?

COLO

I am trying to run python as rmarkdwon code chunks. I was sucessfull but rmarkdown by default uses python2 and I want it to use python 3. I am running it on Ubuntu with python 2.7.6 installed and I installed anaconda with pytthon 3.5, which is the one I want rmarkdown use. Here is the code and output of the python chunk in rmarkdown

```{python}
import sys
print (sys.version)
```

and the output:

2.7.6 (default, Jun 22 2015, 17:58:13) 

Any ideas?

nrussell

You can add engine.path = '/path/to/python3' to override the python (2) executable. For example,

---
title: "python"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{python}
import sys
print(sys.version)
```

```{python, engine.path = '/usr/bin/python3'}
import sys
print(sys.version)
```

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I make the "python" command in terminal, run python3 instead of python2?

From Dev

Insert into (...) - can I use "format" instead of "%s" in Python3?

From Dev

How can I specify a requirement only for Python 2 (ie not Python 3) in requirements.txt?

From Dev

How do I use the python3 version that is installed in Homebrew instead of the one that is installed in the Library?

From Dev

How can I use pip to install python packages for python3?

From Dev

How can I use spell check in Rmarkdown?

From Dev

How can I use my own data set in sklearn - Python3

From Dev

How to instruct jupyter to use python2 not python3

From Dev

How can I specify a python version using setuptools?

From Dev

In Python 3.5, how can I specify a function as a type hint?

From Dev

Python: How can I use ggplot with a simple 2 column array?

From Dev

How can I use a variable instead of a path to open an image file using PIL in Python?

From Dev

What method can I use instead of __file__ in python?

From Dev

What method can I use instead of __file__ in python?

From Dev

How can I get the "old" zip() in Python3?

From Dev

How can I set the path for python3 properly?

From Dev

How can I create dictionary in python3?

From Dev

How can I get pygame for Python3?

From Dev

How can I get pygame for Python3?

From Dev

how can i write a aequivalenz relation in python3?

From Dev

How can I take the datas of a growing list in python3

From Dev

How can i use requestAnimationFrame instead of translate3d?

From Dev

How do I tell dict() in Python 2 to use unicode instead of byte string?

From Dev

why can i not use break on this code and what can i use instead? python

From Dev

python3: how do i format 2 as 02

From Dev

How can I use rmarkdown inline code within a ggtitle

From Java

How do I render Python plots in RMarkdown?

From Java

How can I use Homebrew to install both Python 2 and 3 on Mac?

From Dev

How can i use <symbol> instead of <g>?

Related Related

  1. 1

    How can I make the "python" command in terminal, run python3 instead of python2?

  2. 2

    Insert into (...) - can I use "format" instead of "%s" in Python3?

  3. 3

    How can I specify a requirement only for Python 2 (ie not Python 3) in requirements.txt?

  4. 4

    How do I use the python3 version that is installed in Homebrew instead of the one that is installed in the Library?

  5. 5

    How can I use pip to install python packages for python3?

  6. 6

    How can I use spell check in Rmarkdown?

  7. 7

    How can I use my own data set in sklearn - Python3

  8. 8

    How to instruct jupyter to use python2 not python3

  9. 9

    How can I specify a python version using setuptools?

  10. 10

    In Python 3.5, how can I specify a function as a type hint?

  11. 11

    Python: How can I use ggplot with a simple 2 column array?

  12. 12

    How can I use a variable instead of a path to open an image file using PIL in Python?

  13. 13

    What method can I use instead of __file__ in python?

  14. 14

    What method can I use instead of __file__ in python?

  15. 15

    How can I get the "old" zip() in Python3?

  16. 16

    How can I set the path for python3 properly?

  17. 17

    How can I create dictionary in python3?

  18. 18

    How can I get pygame for Python3?

  19. 19

    How can I get pygame for Python3?

  20. 20

    how can i write a aequivalenz relation in python3?

  21. 21

    How can I take the datas of a growing list in python3

  22. 22

    How can i use requestAnimationFrame instead of translate3d?

  23. 23

    How do I tell dict() in Python 2 to use unicode instead of byte string?

  24. 24

    why can i not use break on this code and what can i use instead? python

  25. 25

    python3: how do i format 2 as 02

  26. 26

    How can I use rmarkdown inline code within a ggtitle

  27. 27

    How do I render Python plots in RMarkdown?

  28. 28

    How can I use Homebrew to install both Python 2 and 3 on Mac?

  29. 29

    How can i use <symbol> instead of <g>?

HotTag

Archive