pythonvisual-studio-codepythoninterpreter

Import numpy in vsCode could not be resolved


I am currently working in VSCode and attempting to import various libraries into my file. I am currently using the interpreter image of interpreter. The remainder of my code is shown remainder of code. I do not understand why my numpy is unable to be imported.


Solution

  • Use the following code to print the current interpreter environment,

    import sys
    print(sys.executable)
    

    Copy the interpreter path and install numpy with

     C:\WorkSpace\pytest10\.venv\Scripts\python.exe -m pip install numpy
    

    Modify C:\WorkSpace\pytest10\.venv\Scripts\python.exe to the path you get

    enter image description here