网状:错误:“导入熊猫”中出现意外符号

时间:2019-07-16 18:12:13

标签: python r

运行以下代码后,我刚遇到错误:

> library(reticulate)
> Sys.which("python")
                             python 
"/data/users/USER/env/bin/python" 
> 
> setwd("/data/users/USER/")
> 
> reticulate::py_discover_config()
python:         /data/users/USER/env/bin/python3.6
libpython:      /usr/lib64/libpython3.6m.so.1.0
pythonhome:     /usr:/usr
version:        3.6.8 (default, Apr 25 2019, 21:02:35)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
numpy:          /data/users/USER/env/lib64/python3.6/site-packages/numpy
numpy_version:  1.16.4

NOTE: Python version was forced by use_python function
> use_python("/data/users/USER/env/bin/python3.6", required = TRUE)
> use_virtualenv("env")
> 
> data_py <- r_to_py(data)
> 
> repl_python()
Python 3.6.8 (/data/users/USER/env/bin/python3.6)
Reticulate 1.12.0.9005 REPL -- A Python interpreter in R.
>>> quit
> import pandas
Error: unexpected symbol in "import pandas"

这很奇怪,因为该代码以前可以工作,我可以从RStudio调用Python命令。基本上没有Python命令可以被识别...

另一个例子:

> repl_python()
Python 3.6.8 (/data/users/USER/env/bin/python3.6)
Reticulate 1.12.0.9005 REPL -- A Python interpreter in R.
>>> quit
> r.data_py['text'] = r.data_py['text'].str.replace("[^a-zA-Z]", " ")
Error: unexpected symbol in "r.data_py['text'] = r.data_py['text'].str.replace"

会话信息:

R version 3.5.2 (2018-12-20)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tidyr_0.8.3            dplyr_0.8.3            reticulate_1.12.0-9005

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        pillar_1.4.2      compiler_3.5.2    remotes_2.1.0     prettyunits_1.0.2 tools_3.5.2      
 [7] digest_0.6.19     pkgbuild_1.0.3    pkgload_1.0.2     jsonlite_1.6      memoise_1.1.0     tibble_2.1.3     
[13] gtable_0.3.0      lattice_0.20-38   pkgconfig_2.0.2   png_0.1-7         rlang_0.4.0       Matrix_1.2-15    
[19] cli_1.1.0         rstudioapi_0.10   curl_3.3          withr_2.1.2       fs_1.3.1          desc_1.2.0       
[25] devtools_2.0.2    rprojroot_1.3-2   grid_3.5.2        tidyselect_0.2.5  glue_1.3.1        R6_2.4.0         
[31] processx_3.4.0    sessioninfo_1.1.1 ggplot2_3.2.0     purrr_0.3.2       callr_3.3.0       magrittr_1.5     
[37] usethis_1.5.1     backports_1.1.4   scales_1.0.0      ps_1.3.0          assertthat_0.2.1  colorspace_1.4-1 
[43] lazyeval_0.2.2    munsell_0.5.0     crayon_1.3.4 

编辑:

更新。 R Studio服务器最近从RStudio 1.1.xxx更新为rstudio-server-1.2.1335-1.x86_64。

当我在RStudio“编辑器”中执行命令时,我得到了错误,但是当我在控制台中执行命令时,我没有得到任何错误...所以这似乎是一个问题。

0 个答案:

没有答案