Visual Studio 2019 python 3.7 64-bit, unresolved import warning

Viewed 3827

I have installed matplotlib and numpy through visual studio, python environments. The following code works fine (plots a sine wave), but the first two lines (imports) are flagged as error/warning in Visual Studio's editor (with that jagged red underline). Is there a reason for that?

I am VERY new to python, so please tell me if I have to provide further information.

import matplotlib.pyplot as plt
import numpy as np

x=np.arange(0,2*np.pi,0.01)
y=np.sin(x)
plt.plot(x,y)
plt.show()
2 Answers

closing and reopening the project did not help, but closing and reopening Visual Studio (after package installation) solved the problem for me.

Can it be that you have multiple Python versions installed?

If yes then you can use the correct python version, it is the same error with me.

Just change the python version in your IDE.

Related