vscode的一些问题
关于python
首先下载安装完vscode后,搜索并下载下面的extensions中的python
配置一下:
file>preferences>settings>extensions>json>Edit in settings.json
在{}中添加python的本地路径
{
“python.analysis.cacheFolderPath”: “C:/Users/Lingo/AppData/Local\Programs/Python/Python37-32”
}
python中第三方包
vscode导入pygame
出现:
vscode Module ‘pygame’ has no ‘init’ member
这样的提示信息
为什么:
“I had the same issue when I started using Visual Studio Code with Python. It has nothing to do with having another pygame.py or not installing it properly. It has to do with the fact that Visual Studio Code takes your code literally, and since you cannot import pygame.init(), it thinks that it isn’t a correct module.”
译:当我开始在Python中使用Visual Studio Code时,我遇到了同样的问题。 它与拥有另一个pygame.py或未正确安装无关。 它与Visual Studio Code照原样接受您的代码有关,并且由于您无法导入pygame.init(),因此认为它不是正确的模块。
解决方法:
file>preferences>settings>extensions>json>Edit in settings.json
{}中添加:
“python.linting.pylintArgs”: ["----extension-pkg-whitelist=pygame"]
本文详细介绍了如何在VSCode中配置Python环境,包括设置Python解释器路径及解决pygame导入错误的方法。通过编辑settings.json文件,添加Python解释器路径和pylint参数,可以避免VSCode对pygame模块的误报。
1万+

被折叠的 条评论
为什么被折叠?



