简体   繁体   中英

Importing the multiarray Numpy extension module failed Visual Studio 2019 Anaconda 1.9.6 Python 3.7.1

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.

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!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM