我已经通过 pip install 下载了请求库,我可以在命令行中使用它,并且可以在 python 的 IDLE 中使用它,但不能在 vscode 中使用。
这是来自 vsc 的代码:
import requests
requests.__version__
Run Code Online (Sandbox Code Playgroud)
这是抛出的错误:
Traceback (most recent call last):
File "/Users/abdourahman/Desktop/webscrape/igscrape.py", line 1, in <module>
import requests
ImportError: No module named requests
Run Code Online (Sandbox Code Playgroud)
在 cmd & IDLE 上运行时,它按预期运行:
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>>
>>> requests.__version__
'2.23.0'
Run Code Online (Sandbox Code Playgroud)
重申一下,我想弄清楚在我的 ide 中访问外部库。我遇到了与vscode&atom以及 bs4 库以及请求相同的问题。