Reputation: 4700
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:
from PIL import Image
img = Image.open('image.png')
img.show()
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()
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
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