This is the code I have:
import pygame
pygame.init()
I\'m very confused because if I try to run the file, then there seems to be no issue,
This answer includes the answer to your question. In short it explains:
Pylint imports modules to effectively identify valid methods and attributes. It was decided that importing c extensions that are not part of the python stdlib is a security risk and could introduce malicious code.
and as a solution it mentions, among others:
Disable safety using the
.pylintrc
settingunsafe-load-any-extensions=yes
.
See here for more information about pylint.rc
. Quickest method is to just create the file .pylintrc
in your project directory or your home directory.
If you are using vscode
then you can go to settings:
python.linting.pylintEnabled = False
It will fix the problem. If you aren't using vscode
then you can go the command prompt and manually uninstall pylint
with the command
pip uninstall pylint.
Summarizing all answers.
This is a security measure to not load non-default C extensions.
You can white-list specific extension(s).
Open user settings and add the following between {}:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
You can allow to "unsafe load" all extensions.
Open user settings and add the following between {}:
"python.linting.pylintArgs": [
"--unsafe-load-any-extension=y"
]
I had the same issue with one of my modules. This is what I did to resolve the problem. (I'm using visual studio on windows 10)
"python.linting.pylintArgs": ["--generate-members"]
below one of the lines (put a comma if necessary).json
file (CTRL+S)For me, the code looks like this :
{
"breadcrumbs.enabled": false,
"editor.minimap.enabled": false,
"python.pythonPath": "C:\\Users\\xxx\\Anaconda3",
"terminal.integrated.rendererType": "dom",
"window.menuBarVisibility": "default",
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": true,
"python.linting.pylintArgs": ["--generate-members"], //line to add
"[json]": {
}
}
Hope it helps. Credit to @Alamnoor on github
I recommend going to the view tab, clicking command palette and searching preferences: open settings.json. Then add a comma on the last line of code.Below that paste this:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
Then save your document (ctrl + s).
Disable Pylint 1.Press ctrl + shift + p 2.Then type Disable Pylint