HarryZhu-7harryprince
运行环境
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reticulate_1.10
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 rstudioapi_0.8 knitr_1.21 magrittr_1.5 usethis_1.4.0 devtools_2.0.1
[7] pkgload_1.0.2 lattice_0.20-38 R6_2.3.0 rlang_0.3.0.1 tools_3.5.2 pkgbuild_1.0.2
[13] grid_3.5.2 xfun_0.4 sessioninfo_1.1.1 cli_1.0.1 withr_2.1.2 remotes_2.0.2
[19] htmltools_0.3.6 rprojroot_1.3-2 yaml_2.2.0 digest_0.6.18 assertthat_0.2.0 crayon_1.3.4
[25] bookdown_0.9 processx_3.2.1 Matrix_1.2-15 callr_3.1.1 fs_1.2.6 ps_1.3.0
[31] glue_1.3.0 memoise_1.1.0 evaluate_0.12 rmarkdown_1.11 compiler_3.5.2 backports_1.1.3
[37] desc_1.2.0 prettyunits_1.0.2 jsonlite_1.6
调用reticulate
```{r setup, include=FALSE}
library(reticulate)
运行
```{python}
print('我')
报错
Warning in strsplit(code, "\n", fixed = TRUE) :
input string 1 is invalid UTF-8
NameError: name 'NA' is not defined
Detailed traceback:
File "<string>", line 1, in <module>
另外,我尝试在Rstudio中运行Python代码,也会出现中文识别问题。
利用Ctrl+Shift+P
运行python('我')
,能够正常输出
> print('我')
[1] "我"
利用Ctrl+Enter
运行python('我')
,中文字符无法正常显示
> reticulate::repl_python()
Python 3.6.5 (C:\Users\wjtt1\MINICO~1\python.exe)
Reticulate 1.10 REPL -- A Python interpreter in R.
>>> print('我')
��