简体   繁体   中英

pylint import error in vscode even though python executer successfully imports it

I am using vscode for coding my python code. I use pandas, numpy and requests library in my code. If I run the code, It works fine. But in VScode editor, in the problems section, always Its says the message as

Unable to import 'numpy' (pylint import error)
Unable to import 'pandas' (pylint import error)
Unable to import 'requests' (pylint import error)

I searched in StackOverflow questions to find the answer to this problem, It says to install pandas using pip . I did that also. But still I am facing the same problem. How to fix this problem in vs code editor

This is not telling you that numpy or pandas is not installed. It is telling you that pylint can't verify your numpy and pandas calls. Most of numpy and pandas is written in C, not Python.

The pylint documentation says

Linting C extension modules is not supported out of the box, especially since pylint has no way to get an AST object out of the extension module.

So there is no problem with your code, even if VSCode says it is a problem. It is a technical limitation of pylint . If it worries you, disable pylint message E401 for these import statements. Put #pylint: disable=E401 on the same line as your import statement.

Check if you have pylint installed. To install pylint, type in the terminal:

$ pip install pylint

(This worked for me)

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