简体   繁体   中英

Visual Studio Code cannot properly reference packages in the virtual environment

I am using VSCODE for my Python development on Windows 10.

As shown in the screenshot below, I use a virtual environment, and my virtual environment includes required libraries.

However, VSCODE shows the following problems:

  • " pyplot ": Unknown word.
  • " numpy ": Unknown word.

The program runs fine . I just need to fix the two problems pointed in the screenshot below:

在此处输入图像描述

It seems that some parts of VSCODE are not considering my virtual environment and try to find the unknown words in the Python installation outside the virtual environment.

How can I properly eliminate the above two "Unknown word" problems?

As an editor, VS Code itself does not display "Unknown word" information. According to the screenshot information you provided, the "Unknown word" information is provided by cSpell.

In VS Code, we use the Linting function provided by the python extension (it contains Pylint, flake8, mypy, etc.) to analyze the python code, and it will display the problems in the code on the VS Code terminal. (Of course, some python language services will also display problems from the code.)

It is recommended that you use the python code analysis tool Pylint when analyzing python code in VS Code. In the code in this thread, it will not display the "Unknown word" message:

在此处输入图像描述

Reference: The use of Pylint in VS Code .

These words actually do not exist in python's dictionary. Add python new words to the python dictionary (click the yellow light bulb with the mouse to see the upper button (the mouse touch the blue circle exclamation mark to see the yellow light bulb)) enter image description here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM