[Solution] VSCode reports an error when running a Python project: ImportError: Unable to import required dependencies: numpy:

foreword

Creation start time: November 17, 2022 14:59:17

As the title, let’s solve ImportError: Unable to import required dependencies: numpy:the solution to the error when running the Python project in VSCode:

Problem Description

Running the project in VSCode, there are a bunch of inexplicable errors:
insert image description here

Specific error output:

PS D:\0-bib\bibtex_parser>  d:; cd 'd:\0-bib\bibtex_parser'; & 'D:\software\Anaconda\envs\apr\python.exe' 'c:\Users\apr\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '50696' '--' 'd:\0-bib\bibtex_parser\Main.py'
D:\software\Anaconda\envs\apr\lib\site-packages\numpy\__init__.py:148: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service     
  from . import _distributor_init
Traceback (most recent call last):
  File "d:\0-bib\bibtex_parser\Main.py", line 4, in <module>
    from pyutils.utils import Regex_util, File_util, List_util, Dataframe_util, Dir_util
  File "d:\0-bib\bibtex_parser\pyutils\utils\Dataframe_util.py", line 1, in <module>
    import pandas as pd
  File "D:\software\Anaconda\envs\apr\lib\site-packages\pandas\__init__.py", line 17, in <module>
    "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "D:\software\Anaconda\envs\apr\python.exe"
  * The NumPy version is: "1.21.5"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: DLL load failed: 找不到指定的模块。

solution

I am stupid.

After thinking about it, I found that VSCode may use Powershell by default instead of Cmd.

Open the settings, search Default shelland find the following:

insert image description here
Change it to:Command Prompt

insert image description here

When running the project again, it is already normal.

summary

that's all.

Creation end time: November 17, 2022 15:03:42

references

All based on personal experience and intuition. . .

  • How do i run a python file in cmd from vscode https://www.it1352.com/2473189.html

Guess you like

Origin blog.csdn.net/weixin_39278265/article/details/127904103