Miladiouss
Miladiouss

Reputation: 4700

VS Code integrated terminal doesn't launch GUI applications

While I'm able to run scripts from Ubuntu terminal, the integrated terminal on VS Code doesn't run correctly when it comes to launching GUI applications. Consider these examples:

PIL Example

from PIL import Image
img = Image.open('image.png')
img.show()

Browser / Plotly Example

import plotly.graph_objects as go
fig = go.Figure(
    data=[go.Bar(y=[2, 1, 3])],
    layout_title_text="A Figure Displayed with fig.show()"
)
fig.show()

Text Editor Example

git rebase -i origin/main

I have reported this bug here but I'm think it may not be a bug.

Upvotes: 1

Views: 2105

Answers (1)

carlfriedrich
carlfriedrich

Reputation: 4019

Probably the DISPLAY variable is not set in your VS code shell. Find out the value in your working system terminal:

echo $DISPLAY

Then set the value in VS Code via the terminal.integrated.env.<platform> setting. Press Ctrl+Shift+P and search for Preferences: Open Settings (JSON). Add the following entry to the settings file:

"terminal.integrated.env.linux": {
    "DISPLAY": "<your-display-value>"
}

Then close and re-open VS Code's terminal. Afterwards, running echo $DISPLAY there should output the same value as in your system terminal. This should make GUI applications launchable.

Upvotes: 1

Related Questions