Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No plot shows up from VS Code

I initiated the VS Code window through a WSL Ubuntu terminal such as

/mnt/d/github/python/python_for_data_science$ code .

And test a plot

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 5, 11)
y = x**2

# functional
plt.plot(x, y)
plt.show()

By Run Python File in Terminal, it shows

/mnt/d/github/python/python_for_data_science$ /usr/bin/python /mnt/d/github/python/python_for_data_science/section_8_matplotlib.py

But I didn't see a plot. Have I missed something?

like image 966
David Z Avatar asked Oct 30 '25 12:10

David Z


1 Answers

WSL might not have the ability to show UI. Alternatively you can run the code in the Python Interactive window in order to see the output. Try right-click and select Run Current File in Python Interactive window.

like image 88
CodeBunny Avatar answered Nov 01 '25 01:11

CodeBunny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!