【发布时间】:2020-04-22 11:44:19
【问题描述】:
要详细说明标题,
我正在使用 rstudio 制作一个包含 r 和 python 代码的 rmarkdown 文件。我的配置如下:
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rstudioapi_0.11 knitr_1.28 magrittr_1.5 rappdirs_0.3.1 tidyselect_1.0.0
[7] munsell_0.5.0 lattice_0.20-38 colorspace_1.4-1 R6_2.4.1 rlang_0.4.5 dplyr_0.8.5
[13] tools_3.6.3 grid_3.6.3 gtable_0.3.0 xfun_0.12 htmltools_0.4.0 yaml_2.2.1
[19] assertthat_0.2.1 digest_0.6.25 tibble_2.1.3 lifecycle_0.2.0 crayon_1.3.4 Matrix_1.2-18
[25] purrr_0.3.3 ggplot2_3.3.0 rsconnect_0.8.16 glue_1.3.2 evaluate_0.14 rmarkdown_2.1
[31] compiler_3.6.3 pillar_1.4.3 scales_1.1.0 jsonlite_1.6.1 reticulate_1.15-9000 pkgconfig_2.0.3
我尝试运行的 python 块是:
import scipy as sp
import numpy as np
import pandas as pd
df = pd.read_csv("D:/03 PhD Edinburgh related/OneDrive/OneDrive - University of Edinburgh/00 PhD/000 PhD Data/01 Project I Chr Hansen/20200421_analysis_pp16013/20200420_pp16013_analysis.csv")
plt.scatter(df['OD'].values, df['osmolarity.mOSM'].values,
c=df['hydrophobicity'].values,cmap='magma')
plt.xlabel('OD')
plt.ylabel('osmolarity')
plt.title('osmolarity as function of OD and Hydrophobicity')
cbar = plt.colorbar()
cbar.set_label('Hydrophobicity', rotation=270)
plt.show()
我可以在 rStudio 中正常运行 python 块并按预期显示图形。
当我尝试使用 knitter 制作文档时,它会到达 python 块并给出错误:
"This application failed to start because it could not find or load
the Qt platform plugin "windows" in "",
reinstalling the application may fix this problem."
这与使用matplotlib的部分特别相关。我可以创建和显示 Pandas 数据框。
我已经尝试安装最新版本的github reticulate。
提前感谢您的帮助。
【问题讨论】:
-
您是否尝试用谷歌搜索此错误消息?我找到了this
-
是的,谷歌透露它很可能与网状包有关。我按照说明通过直接从 github 安装包来更新到最新版本。
-
但是我提供的链接谈到了发生此错误时要修改的 PATH。
标签: r knitr reticulate