簡體   English   中英

vscode找不到python的請求庫

[英]vscode can't find python's requests library

我已經通過 pip install 下載了 requests 庫,我可以在我的命令行上使用它,也可以在 python 的 IDLE 中使用它,但不能在 vscode 中使用。

這是來自 vsc 的代碼:

import requests

requests.__version__

這是拋出的錯誤:

Traceback (most recent call last):
  File "/Users/abdourahman/Desktop/webscrape/igscrape.py", line 1, in <module>
    import requests
ImportError: No module named requests

在 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'

重申一下,我想弄清楚在我的 ide 中訪問外部庫。 我遇到了同樣的問題vscode & atom ,以及 bs4 庫和請求。

問題是我在 vscode 中運行源代碼的 Code Runner 擴展。 關閉它,它默認在vscode中從終端運行python,解決了無法找到模塊的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM