vscode关于python的设置

本文详细介绍了如何在VSCode中配置Python环境,包括设置Python解释器路径及解决pygame导入错误的方法。通过编辑settings.json文件,添加Python解释器路径和pylint参数,可以避免VSCode对pygame模块的误报。

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"]

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值