Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 669
Basit Anwer Avatar asked Dec 24 '22 05:12

Basit Anwer


2 Answers

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.

like image 75
andresgottlieb Avatar answered Dec 26 '22 18:12

andresgottlieb


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"] } },

like image 24
Don Avatar answered Dec 26 '22 19:12

Don