【发布时间】:2019-11-11 05:57:14
【问题描述】:
编辑找到解决方案。 Plot Python Plots Inline
我一直在制作一个 Rmarkdown 笔记本来记录我的 Python 研究。在 RStudio 中,我已经能够毫无问题地将包含我的 python 代码的文档编织成 HTML,直到我开始使用 matplotlib 绘制数据。奇怪的是,这些图是在代码块中正确生成的。但是编织后,每次80%就吐一个错误。
这是我的示例代码:
---
title: "Python Plot"
output: html_document
---
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
library(reticulate) #Allows for Python to be run in chunks
```
```{python, eval=F}
import numpy as np
trees = np.array(r.trees) #Imported an internal R dataset. It got rid of headers and first row. Don't know how to deal with that right now.
type(trees)
np.shape(trees)
print(trees[1:6,:])
import matplotlib.pyplot as plt
plt.plot(trees[:,0], trees[:,1])
plt.show()
plt.clf() #Reset plot surface
```
再一次,这个情节在块内处理时表现得很好,但没有编织。错误消息说,
"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."
我已经卸载并重新安装了 Rstudio 和 Python 并继续得到相同的结果。我觉得奇怪的是它可以在块中工作,但不能编织到 HTML。我所有的其他 python 代码都很好。
我有
python 3.7.3(默认,2019 年 3 月 27 日,17:13:21)[MSC v.1915 64 位 (AMD64)]
Rstudio 版本 1.2.1335。
我已阅读其他解决方案。我相信 libEGL.dll 与所有其他 QT5*.dll 位于同一位置。
【问题讨论】:
-
尝试谷歌搜索该错误消息:此应用程序无法启动,因为它无法找到或加载 Qt 平台插件“windows”。各种命中可能会有用。
-
谢谢,我申请了,但有些没有申请,有些似乎远高于我的水平。我只是不明白为什么它在环境中起作用。
-
@Ken,它可能是重复的。我刚刚花了最后一个小时或更长时间阅读并尝试做事,但我不得不承认我的无能。我不明白。我不知道它是否重复。我不这么认为,因为我相信所有合适的 .dll 都在正确的位置。我不知道为什么它会毫无错误地编织其他 python 代码。我不知道为什么它会在块中绘制 pythod 代码。它只是不会用 python 图编织任何代码。我感谢链接,但我想我会放弃。
标签: python anaconda rstudio r-markdown knitr