I have a fresh install of Anaconda (1.9.6) and elected to install Visual Studio 2019 as part of this process. The code below executes without error in the Spyder IDE bundled with Anaconda, but in Visual Studio it returns the following error:
"Importing the multiarray numpy extension module failed. Most likely you are trying to import a failed build of numpy. If you're working with a numpy git repo, try git clean -xdf
(removes all files not under version control). Otherwise reinstall numpy. Original error was: DLL load failed: The specified module could not be found."
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100) # Create a list of evenly-spaced numbers over the range
plt.plot(x, np.sin(x)) # Plot the sine of each x point
plt.show() # Display the plot
My Python environment in VS is Python 3.7.1 64-bit ('base':conda). I believe I am using the same Python environment as Anaconda and I have never installed Python on this machine before. Further, I am not working with a "numpy git repo".
My questions are these:
Why does Visual Studio fail to import Numpy when Spyder can and they share environments? and How do I make Visual Studio work with Numpy?
Note, although this may look like a duplicate question, other questions have used previous VS releases (which refer to Solutions Explorer, which VS2019 no longer has), don't start with Anaconda as the Python environment, or refer to Python 2.x.