4
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

2
  • 1
    Try a pip install numpy first, since VS might not have the library pre-installed. Commented May 10, 2016 at 15:36
  • 1
    Did that. I had numpy pre-installed. Did so again but no effect Commented May 11, 2016 at 7:36

4 Answers 4

5

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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

Comments

3

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.

1 Comment

thank you very much, I had a problem with python version in my terminal, reinstalling the extension fixed the problem.
1

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.