1
votes

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.

1
I should add that Visual Studio is version 1.32 and is the February 2019 releaseRDavey

1 Answers

0
votes

I have the same problem. I haven't solved it properly, but if I instead create a virtual environment with python 3.6 it works fine..(I would have added this as a comment, but I'm unable to!)