Python code inside Flexdashboard framework

Hi guys,

Has anyone tried to run python chunk codes inside a flexdashboard framework?
I keep getting this error "TypeError: float() argument must be a string or a number, not 'list'"

For example, the first chunk in R get some input

dateInput("startdate_r", "Start Date:", value = "2019-02-29")
dateInput("enddate_r", "End Date:", value = "2019-04-29")

and the second chunk in python tries to read it

#Something like that
print("hello")

Hi,

do you have a real minimal reprex you tried ?
It would help see what you are trying to do.

To interface R and python, you should look at

And how it works with Rmarkdown
https://rstudio.github.io/reticulate/articles/r_markdown.html

From your small piece of code, I understand you are trying to use flexdashboad with Shiny, right ?

This could be a little difference I guess - hence an important precision.

Yes, I am basically trying to use the flexdashboard with shiny to create a simple interactive dashboard using all the exploratory analysis and modeling that I have done in Python. As I stated above, flexdashboard with shiny currently does not support any python code inside the markdown template however if you were to switch the template from flexdashboard to an html_document format, it would work. I was wondering if there was a way around that.

---
title: "Test"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
  orientation: columns
  vertical_layout: fill

---

```{r setup, include=FALSE}
library(flexdashboard)
library(reticulate)
library(dplyr)
library(shiny)
library(shinydashboard)
library(reticulate)
```


```{r}
dateInput("startdate_r", "Start Date:", value = "2012-02-29")
dateInput("enddate_r", "End Date:", value = "2012-04-29")

```



Column
-------

```{python}
print("hello")
```

Thanks for the reproductible example. I can reproduce the error. For now I don't know where it comes from but there is indeed something going on...

There is an open issue related to your problem I think

@lyansaud can you specify your OS and you Python version ?

devtools::session_info() and reticulate::py_config()

reticulate::py_config()
python: /Users/lyansaud/anaconda3/bin//python
libpython: /Users/lyansaud/anaconda3/lib/libpython3.7m.dylib
pythonhome: /Users/lyansaud/anaconda3:/Users/lyansaud/anaconda3
version: 3.7.0 (default, Jun 28 2018, 07:39:16) [Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: /Users/lyansaud/anaconda3/lib/python3.7/site-packages/numpy
numpy_version: 1.16.2

python versions found:
/Users/lyansaud/anaconda3/bin//python
/usr/bin/python
/usr/local/bin/python3
/Users/lyansaud/anaconda3/bin/python
/anaconda3/envs/r-kernel/bin/python
/anaconda3/envs/r-tensorflow/bin/python

─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.5.2 (2018-12-20)
os macOS High Sierra 10.13.6
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Los_Angeles
date 2019-11-19

─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.5.2 (2018-12-20)
os macOS High Sierra 10.13.6
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Los_Angeles
date 2019-11-19

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
abind 1.4-5 2016-07-21 [1] CRAN (R 3.5.0)
askpass 1.1 2019-01-13 [1] CRAN (R 3.5.2)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.2)
backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.0)
BiasedUrn 1.07 2015-12-28 [1] CRAN (R 3.5.0)
bit 1.1-14 2018-05-29 [1] CRAN (R 3.5.0)
bit64 0.9-7 2017-05-08 [1] CRAN (R 3.5.0)
bitops * 1.0-6 2013-08-17 [1] CRAN (R 3.5.0)
blob 1.1.1 2018-03-25 [1] CRAN (R 3.5.0)
boot 1.3-20 2017-08-06 [1] CRAN (R 3.5.2)
brew 1.0-6 2011-04-13 [1] CRAN (R 3.5.0)
broom 0.5.1 2018-12-05 [1] CRAN (R 3.5.0)
callr 3.1.1 2018-12-21 [1] CRAN (R 3.5.0)
car 3.0-2 2018-08-23 [1] CRAN (R 3.5.0)
carData 3.0-2 2018-09-30 [1] CRAN (R 3.5.0)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.5.0)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.2)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.5.2)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.0)
curl 3.3 2019-01-10 [1] CRAN (R 3.5.2)
data.table * 1.12.0 2019-01-13 [1] CRAN (R 3.5.2)
data.tree 0.7.8 2018-09-24 [1] CRAN (R 3.5.0)
DBI * 1.0.0 2018-05-02 [1] CRAN (R 3.5.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.0)
devtools 2.0.1 2018-10-26 [1] CRAN (R 3.5.2)
DiagrammeR 1.0.0 2018-03-01 [1] CRAN (R 3.5.0)
digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.0)
diptest 0.75-7 2016-12-05 [1] CRAN (R 3.5.0)
downloader 0.4 2015-07-09 [1] CRAN (R 3.5.0)
dplyr * 0.8.0.1 2019-02-15 [1] CRAN (R 3.5.2)
DT 0.2.10 2019-03-26 [1] Github (rstudio/DT@bf60e43)
evaluate 0.13 2019-02-12 [1] CRAN (R 3.5.2)
flipAPI * 0.1 2019-03-26 [1] Github (Displayr/flipAPI@b2a65d3)
flipFormat 1.2.1 2019-03-26 [1] Github (Displayr/flipFormat@6e4422e)
flipTime 2.8.1 2019-03-26 [1] Github (Displayr/flipTime@3d0d3bc)
flipTransformations 1.6.9 2019-03-26 [1] Github (Displayr/flipTransformations@c8e2eb7)
flipU 1.2.4 2019-03-26 [1] Github (Displayr/flipU@e648df8)
forcats * 0.3.0 2018-02-19 [1] CRAN (R 3.5.0)
foreign 0.8-71 2018-07-20 [1] CRAN (R 3.5.2)
formattable 0.2.0.2 2019-03-26 [1] Github (renkun-ken/formattable@39e1e01)
fs 1.2.6 2018-08-23 [1] CRAN (R 3.5.0)
gdata * 2.18.0 2017-06-06 [1] CRAN (R 3.5.0)
generics 0.0.2 2018-11-29 [1] CRAN (R 3.5.0)
GGally 1.4.0 2018-05-17 [1] CRAN (R 3.5.0)
ggplot2 * 3.1.0 2018-10-25 [1] CRAN (R 3.5.0)
ggrepel 0.8.0 2018-05-09 [1] CRAN (R 3.5.0)
ggridges 0.5.1 2018-09-27 [1] CRAN (R 3.5.0)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.2)
GPArotation 2014.11-1 2014-11-25 [1] CRAN (R 3.5.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.5.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.5.2)
gtools * 3.8.1 2018-06-26 [1] CRAN (R 3.5.0)
haven 2.0.0 2018-11-22 [1] CRAN (R 3.5.0)
hms 0.4.2 2018-03-10 [1] CRAN (R 3.5.0)
htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.0)
htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.5.0)
httr * 1.4.0 2018-12-11 [1] CRAN (R 3.5.0)
igraph 1.2.4 2019-02-13 [1] CRAN (R 3.5.2)
influenceR 0.1.0 2015-09-03 [1] CRAN (R 3.5.0)
janitor * 1.1.1 2018-07-31 [1] CRAN (R 3.5.0)
jsonlite * 1.6 2018-12-07 [1] CRAN (R 3.5.0)
knitr 1.22 2019-03-08 [1] CRAN (R 3.5.2)
lattice 0.20-38 2018-11-04 [1] CRAN (R 3.5.2)
lavaan 0.6-3 2018-09-22 [1] CRAN (R 3.5.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.5.2)
lme4 1.1-21 2019-03-05 [1] CRAN (R 3.5.2)
lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.5.0)
magrittr * 1.5 2014-11-22 [1] CRAN (R 3.5.0)
MASS 7.3-51.1 2018-11-01 [1] CRAN (R 3.5.2)
Matrix 1.2-15 2018-11-01 [1] CRAN (R 3.5.2)
MBESS 4.4.3 2018-01-10 [1] CRAN (R 3.5.0)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0)
minpack.lm 1.2-1 2016-11-20 [1] CRAN (R 3.5.0)
minqa 1.2.4 2014-10-09 [1] CRAN (R 3.5.0)
mnormt 1.5-5 2016-10-15 [1] CRAN (R 3.5.0)
modelr 0.1.2 2018-05-11 [1] CRAN (R 3.5.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.0)
nlme 3.1-137 2018-04-07 [1] CRAN (R 3.5.2)
nloptr 1.2.1 2018-10-03 [1] CRAN (R 3.5.0)
odbc * 1.1.6 2018-06-09 [1] CRAN (R 3.5.0)
openxlsx 4.1.0 2018-05-26 [1] CRAN (R 3.5.0)
packrat 0.5.0 2018-11-14 [1] CRAN (R 3.5.0)
pander 0.6.3 2018-11-06 [1] CRAN (R 3.5.0)
pbivnorm 0.6.0 2015-01-23 [1] CRAN (R 3.5.0)
pdftools * 2.2 2019-03-10 [1] CRAN (R 3.5.2)
pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.0)
pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.5.0)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.0)
plotly 4.8.0 2018-07-20 [1] CRAN (R 3.5.2)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.5.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.0)
processx 3.2.1 2018-12-05 [1] CRAN (R 3.5.0)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.0)
psych 1.8.12 2019-01-12 [1] CRAN (R 3.5.2)
purrr * 0.3.2 2019-03-15 [1] CRAN (R 3.5.2)
pwr 1.2-2 2018-03-03 [1] CRAN (R 3.5.0)
qpdf 1.1 2019-03-07 [1] CRAN (R 3.5.2)
R.methodsS3 * 1.7.1 2016-02-16 [1] CRAN (R 3.5.0)
R.oo * 1.22.0 2018-04-22 [1] CRAN (R 3.5.0)
R.utils * 2.7.0 2018-08-27 [1] CRAN (R 3.5.0)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.5.0)
Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.2)
RCurl * 1.95-4.12 2019-03-04 [1] CRAN (R 3.5.2)
readr * 1.3.1 2018-12-21 [1] CRAN (R 3.5.0)
readxl * 1.3.1 2019-03-13 [1] CRAN (R 3.5.2)
remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.0)
reshape 0.8.8 2018-10-23 [1] CRAN (R 3.5.0)
rgeolocate 1.0.1 2017-08-02 [1] CRAN (R 3.5.0)
rgexf 0.15.3 2015-03-24 [1] CRAN (R 3.5.0)
RGoogleAnalytics 0.1.5 2019-03-26 [1] Github (Tatvic/RGoogleAnalytics@fa27bb6)
rhtmlMetro 0.1.1 2019-03-26 [1] Github (Displayr/rhtmlMetro@b51bab0)
rio 0.5.16 2018-11-26 [1] CRAN (R 3.5.0)
rJava 0.9-11 2019-03-29 [1] CRAN (R 3.5.2)
rjson * 0.2.20 2018-06-08 [1] CRAN (R 3.5.0)
rlang 0.3.4 2019-04-07 [1] CRAN (R 3.5.2)
rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.5.2)
RMySQL * 0.10.16 2019-01-04 [1] CRAN (R 3.5.2)
RODBC * 1.3-15 2017-05-05 [1] CRAN (R 3.5.0)
Rook 1.1-1 2014-10-20 [1] CRAN (R 3.5.0)
RPostgreSQL * 0.6-2 2017-06-24 [1] CRAN (R 3.5.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0)
rstudioapi 0.9.0 2019-01-09 [1] CRAN (R 3.5.2)
rvest * 0.3.2 2016-06-17 [1] CRAN (R 3.5.0)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.0)
scrobbler 0.1.0 2019-01-08 [1] CRAN (R 3.5.2)
SCRT 1.2.2 2018-03-07 [1] CRAN (R 3.5.0)
selectr 0.4-1 2018-04-06 [1] CRAN (R 3.5.0)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.0)
sparkline 2.0 2016-11-12 [1] CRAN (R 3.5.0)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.2)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 3.5.2)
SuppDists 1.1-9.4 2016-09-23 [1] CRAN (R 3.5.0)
testthat 2.0.1 2018-10-13 [1] CRAN (R 3.5.0)
tibble * 2.1.1 2019-03-16 [1] CRAN (R 3.5.2)
tidyr * 0.8.3 2019-03-01 [1] CRAN (R 3.5.2)
tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.0)
tidyverse * 1.2.1 2017-11-14 [1] CRAN (R 3.5.0)
userfriendlyscience * 0.7.2 2018-09-24 [1] CRAN (R 3.5.0)
usethis 1.4.0 2018-08-14 [1] CRAN (R 3.5.0)
V8 * 1.5 2017-04-25 [1] CRAN (R 3.5.0)
viridis 0.5.1 2018-03-29 [1] CRAN (R 3.5.0)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.5.0)
visNetwork 2.0.6 2019-03-26 [1] CRAN (R 3.5.2)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0)
xfun 0.7.4 2019-06-13 [1] Github (yihui/xfun@cc966d3)
xgboost 0.6.4.6 2019-03-28 [1] local
XLConnect * 0.2-15 2018-04-05 [1] CRAN (R 3.5.0)
XLConnectJars * 0.2-15 2018-04-05 [1] CRAN (R 3.5.0)
XML * 3.98-1.19 2019-03-06 [1] CRAN (R 3.5.2)
xml2 * 1.2.0 2018-01-24 [1] CRAN (R 3.5.0)
xtable 1.8-3 2018-08-29 [1] CRAN (R 3.5.0)
zip 2.0.1 2019-03-11 [1] CRAN (R 3.5.2)
zoo * 1.8-4 2018-09-19 [1] CRAN (R 3.5.0)

[1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library

reticulate::py_config()
python: /Users/lyansaud/anaconda3/bin//python
libpython: /Users/lyansaud/anaconda3/lib/libpython3.7m.dylib
pythonhome: /Users/lyansaud/anaconda3:/Users/lyansaud/anaconda3
version: 3.7.0 (default, Jun 28 2018, 07:39:16) [Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: /Users/lyansaud/anaconda3/lib/python3.7/site-packages/numpy
numpy_version: 1.16.2

python versions found:
/Users/lyansaud/anaconda3/bin//python
/usr/bin/python
/usr/local/bin/python3
/Users/lyansaud/anaconda3/bin/python
/anaconda3/envs/r-kernel/bin/python
/anaconda3/envs/r-tensorflow/bin/python

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.