Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python chunk fails to run in windows desktop version with error: This application failed to start because it could not find or load the Qt platform plugin "windows" in "". #4182

Closed
andresrcs opened this issue Jan 19, 2019 · 26 comments · Fixed by #5051

Comments

@andresrcs
Copy link

commented Jan 19, 2019

System details

RStudio Edition : Desktop
RStudio Version : 1.2.1242
OS Version      : Windows 10 Pro
R Version       : 3.5.2

Steps to reproduce the problem

Run this simple python chunk

---
title: "R Notebook"
output: html_notebook
---

```{python}
import pandas
```

Describe the problem in detail

When I try to run a python chunk y get this error and my R session crashes.
image

I have python installed through Anaconda 3 distribution, this used to work normally some daily builds ago, but I can't specify which one.

@kevinushey

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2019

This should work with the development builds of reticulate. What is the output of packageVersion("reticulate") on your machine?

Does:

devtools::install_github("rstudio/reticulate")

make a difference?

@andresrcs

This comment has been minimized.

Copy link
Author

commented Jan 22, 2019

My reticulate version was 1.10, I have installed the development version and now works normally, thanks.

@ronblum

This comment has been minimized.

Copy link

commented Feb 8, 2019

On MacOS, the current version of reticulate ((1.10) causes a new RStudio instance to start to open, but remains bouncing and doing nothing. It requires quitting the app to keep going. The development build works, though.

I'm leaving this marked as an open issue, to retest once a new production version reticulate is published.

@ronblum ronblum added the bug label Feb 8, 2019
@icalandra

This comment has been minimized.

Copy link

commented Jun 27, 2019

I still have the same problem, as described by @andresrcs

Windows 10 Pro, version 1803, OS build 17134.829
Anaconda 3 with Python 3.7.3
R 3.6.0
RStudio 1.2.1335
reticulate 1.12.0.9003

The problem seems to be only with Python plotting commands, other Python calculations seem fine.
I searched quite a lot online but I cannot understand any of the answers.

Thanks for any help!

@kevinushey kevinushey added this to the v1.2-patch milestone Jun 27, 2019
@kevinushey

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2019

@icalandra I suspect your issue is different. @andresrcs's issue involved RStudio crashing even when pandas was imported; yours is explicitly around plotting.

A reproducible example would be helpful.

@icalandra

This comment has been minimized.

Copy link

commented Jun 28, 2019

Thanks for the answer.

Indeed, my problem seems to be different, although the error is the same, which is why I thought the problem was similar.

I can plot Python commands from a Python script or directly writing in the console. But I cannot knit it:

---
title: "Untitled"
author: "xx"
date: "28/06/2019"
output: html_document
---

```{python}
import numpy as np
from matplotlib import pyplot as plt
xs = np.linspace(0,10)
ys = 3*xs +1
```

```{python}
fig, ax = plt.subplots()
ax.plot(xs,ys)
plt.show()
```

The first chunk runs fine and exports to HTML correctly (if I remove the second chunk), but the second crashes and I get the error shown in the original thread. Any idea?
Thanks,
Ivan

@icalandra

This comment has been minimized.

Copy link

commented Jun 28, 2019

Oh, I didn't expect the markdown part would be interpreted; how can I avoid it?
But I guess you got it.

@kevinushey

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

You can use backtick code 'fences' to avoid that sort of rendering, e.g.

`````
# This is some Markdown

```{r}
print("Hello!")
```
`````

I've edited your post to do that (hope that's okay).

@icalandra

This comment has been minimized.

Copy link

commented Jul 1, 2019

@kevinushey thanks for the tip!
The real problem still remains though...

@icalandra

This comment has been minimized.

Copy link

commented Jul 9, 2019

Any pointer anyone?
Thanks again!

@ronblum

This comment has been minimized.

Copy link

commented Jul 9, 2019

@icalandra The fix for both issues—covered by #5051—is slated for the upcoming update to 1.2.

@icalandra

This comment has been minimized.

Copy link

commented Jul 10, 2019

Great, thanks!

@ronblum

This comment has been minimized.

Copy link

commented Jul 10, 2019

@icalandra You're welcome! When the next preview is available, this should be working. If you're still running into the issue then, please let us know!

@ronblum ronblum closed this Jul 10, 2019
@kevinushey kevinushey reopened this Jul 10, 2019
@icalandra

This comment has been minimized.

Copy link

commented Jul 11, 2019

I will!

@ronblum

This comment has been minimized.

Copy link

commented Jul 30, 2019

@icalandra Have you had a chance to try out the latest preview and see if it works?

@icalandra

This comment has been minimized.

Copy link

commented Jul 31, 2019

Euu... how do I install it?
I currently have reticulate 1.13.0.9000 installed and I still have the issue

@ronblum

This comment has been minimized.

Copy link

commented Jul 31, 2019

@icalandra I'm sorry—I meant the RStudio preview at https://www.rstudio.com/products/rstudio/download/preview/. (Note that Preview builds are intended for testing purposes only.)

@ronblum

This comment has been minimized.

Copy link

commented Jul 31, 2019

The original issue is confirmed, using the current production version of reticulate, 1.13. I'm leaving this in "verifying" state, for the moment, because of the second issue.

@icalandra

This comment has been minimized.

Copy link

commented Aug 1, 2019

I can confirm that the problem persists with the latest RStudio preview (1.2.1565).

@ronblum

This comment has been minimized.

Copy link

commented Aug 1, 2019

I get a different error, even though the plot is rendered. In the R Markdown pane, the log ends with

Fatal Python error: PyEval_RestoreThread: NULL tstate

The error modal below appears, as well. There's no problem if the file only contains the first chunk when knitted, or if the chunks are running individually. So even though we're getting different results, it seems like your original issue is still there, so I'm reopening.

python

@ronblum ronblum reopened this Aug 1, 2019
@jmcphers jmcphers removed the verifying label Aug 13, 2019
@jmcphers jmcphers assigned kevinushey and unassigned ronblum Aug 13, 2019
@dfalty dfalty changed the title Python chunch fails to run in windows desktop version with error: This application failed to start because it could not find or load the Qt platform plugin "windows" in "". Python chunk fails to run in windows desktop version with error: This application failed to start because it could not find or load the Qt platform plugin "windows" in "". Aug 13, 2019
@linderd

This comment has been minimized.

Copy link

commented Aug 14, 2019

I found a walkaround to solve the problem with the help from this stackoverflow
The solution was to add these two lines to the R code:
py_run_string("import os as os")
py_run_string("os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:/Path_to_your_anaconda/anaconda3/Library/plugins/platforms'")

Hope I could help you

EDIT: Works fine but I still get a crash when I terminate my execution.

@ronblum ronblum self-assigned this Aug 16, 2019
@icalandra

This comment has been minimized.

Copy link

commented Aug 19, 2019

The code chuncks do run, but I get an error at the end and no HTML file as a result. Did I do something wrong?

Here is my code:

---
title: "Untitled"
author: "xx"
date: "28/06/2019"
output: html_document
---

```{r}
library(reticulate)
py_run_string("import os as os")
py_run_string("os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:/Users/.../Anaconda3/Library/plugins/platforms'")
```

```{python}
import numpy as np
from matplotlib import pyplot as plt
xs = np.linspace(0,10)
ys = 3*xs +1
```

```{python}
fig, ax = plt.subplots()
ax.plot(xs,ys)
plt.show()
```

And here is the error:
output file: test2.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS test2.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output test2.html --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\calandra\Documents\R\win-library\3.6\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\calandra\AppData\Local\Temp\Rtmp2bgJSj\rmarkdown-str29544bf85fbb.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
Access violation in generated code when executing data at 0x7a48e89
Attempting to reconstruct a stack trace...
Frame Code address

  • 0x57adaf0 0x7a48e89
  • 0x57adaf8 0x1d40101 C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x1940101
  • 0x57adb00 0xd70
  • 0x57adb08 0x22e
  • 0x57adb10 0x58d4510
  • 0x57adb18 0x5
  • 0x57adb20 0x73020d0000
  • 0x57adb28 0x22e
  • 0x57adb30 0xc68
  • 0x57adb38 0x7aa5c09
  • 0x57adb40 0x7a08491
  • 0x57adb48 0x20
  • 0x57adb50 0x61
  • 0x57adb58 0x7af6fa1
  • 0x57adb60 0x7af80e8
  • 0x57adb68 0x7af81a8
  • 0x57adb70 0x7af8180
  • 0x57adb78 0x7aed6d1
  • 0x57adb80 0x1
  • 0x57adb88 0x57
  • 0x57adb90 0x7a794d0
  • 0x57adb98 0x4f
  • 0x57adba0 0x7a2df08
  • 0x57adba8 0x7ad8481
  • 0x57adbb0 0x4b61721 C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x4761721
  • 0x57adbb8 0x49f2be2 C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x45f2be2
  • 0x57adbc0 0x4b616f1 C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x47616f1
  • 0x57adbc8 0x423fbc8 C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x3e3fbc8
  • 0x57adbd0 0x7ac0540
  • 0x57adbd8 0x7ac0509
  • 0x57adbe0 0x49f0aba C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x45f0aba
  • 0x57adbe8 0x49f0aba C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x45f0aba
  • 0x57adbf0 0x423fba8 C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x3e3fba8
  • 0x57adbf8 0x49f0aba C:\PROGRA~1\RStudio\bin\pandoc\pandoc.exe+0x45f0aba
  • 0x57adc00 0x7ac0680
    ... (maximum recursion depth reached.)
    Error: pandoc document conversion failed with error 11
    Execution halted
@kevinushey

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

@icalandra are you using the preview release of RStudio?

@icalandra

This comment has been minimized.

Copy link

commented Aug 27, 2019

I just tried again with the latest preview release of RStudio (1.2.1572) and @linderd solution works, without errors:

---
title: "Untitled"
author: "xx"
date: "28/06/2019"
output: html_document
---

```{r}
library(reticulate)
py_run_string("import os as os")
py_run_string("os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:/Users/calandra/Anaconda3/Library/plugins/platforms'")
```

```{python}
import numpy as np
from matplotlib import pyplot as plt
xs = np.linspace(0,10)
ys = 3*xs +1
```

```{python}
fig, ax = plt.subplots()
ax.plot(xs,ys)
plt.show()
```

So it seems to all work correctly now, thank you all for your help!

@kevinushey

This comment has been minimized.

Copy link
Contributor

commented Aug 27, 2019

As far as I can tell, all of the associated issues in this thread have been fixed (with the workaround for QP_QPA_PLATFORM_PLUGIN_PATH). I've filed an issue on the reticulate side to see if we can handle that better:

rstudio/reticulate#586

Since this issue has become rather long and unwieldy, if you find you're still running into a problem please open a new issue (with a reproducible example). Thanks!

@kevinushey kevinushey closed this Aug 27, 2019
@ronblum ronblum added the verified label Aug 27, 2019
@icalandra

This comment has been minimized.

Copy link

commented Aug 28, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.