'Debug Python from Visual Studio Code - Importing Numpy
import numpy
print "asdf"
When I try to debug/run the above Python code in Visual Studio Code I get the following error (Using OSX)
ImportError, cannot import name float96
What is the resolution ?
I have installed python from the python website. Tried to run after installing from brew too but no effect.
EDIT
The problem is with all imports for Visual Studio
Solution 1:[1]
Re-insatlling python extension solved my issue. It was not a problem of configuration after all.
https://code.visualstudio.com/docs/languages/python_c
Tip: Don Jayamanne's Python extension gives you the option of using three different linters - Pylint, Pep8, and Flake8. See the wiki for more details.
Solution 2:[2]
In my case, the problem was that vscode was using the python (v2) interpreter but I had installed the module using python3.
I fixed this modifying the launch.json file and specifying the pythonPath for python3, as explained here.
Solution 3:[3]
this is an issue with the debugger, in the manner in which it loads the modules and such import errors can be safely ignored. To ignore these errors, please go into the launch.json file and edit it as follows (to add the section to ignore the "ImportError"):
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
],
"exceptionHandling": {
"ignore": ["ImportError"]
}
},
Solution 4:[4]
I had this issue because I had a conflicting install of Anaconda in the system that I was in the middle of removing. Once I cleaned up all vestiges of anaconda from my shell, it started working!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Basit Anwer |
Solution 2 | Community |
Solution 3 | Don |
Solution 4 | Alex Joseph |