以前在知乎上看到开源的VS code,感受很喜欢这种风格,遂更换掉以前的sublimeText和Atompython
由于以前在学习Java,因此用IDEA比较多,所以安装完就没有用太屡次。最近,又开始用Python学习和写一些爬虫,每次都打开pyCharm比较麻烦,因此想着用VS code方便多了。结果,每次写完之后须要运行的时候,发现老是出现ImportError: No module named requests错误。shell
因而,我先排查了本身安装了这些库没有,屡次检查后发现是安装好的,能够在终端中经过如下命令查看已安装好的库json
$pydoc modules
或者进入Python中学习
>>> help("modules")
两种方法的效果是同样ui
以后,经过查阅Google,更改了屡次settings.json,仍是不行。spa
最后在Stack Overflow上看到做者说这是一个BUG
发现须要经过Mac:command+shift+B(Win:Ctrl+Shift+B)
选择Other,新建运行脚本
而后把下列代码输入到tasks.json中code
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { // Python路径 "command": "/usr/local/bin/python3", // 名称 "label": "python3", "type": "shell", "args": [ "${file}" ], "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": true, "clear": false }, "group": { "kind": "build", "isDefault": true } } ] }
每次运行Python3的时候用command+Shift+B运行便可orm