Python 获得;名称错误:名称';请求';“未定义”;已安装请求后(使用JuypterLab)

Python 获得;名称错误:名称';请求';“未定义”;已安装请求后(使用JuypterLab),python,beautifulsoup,nameerror,Python,Beautifulsoup,Nameerror,我已经使用'pip install requests'安装了请求,但我没有得到任何回报 我正在按照basic中给出的示例进行操作,并在code上不断得到这个错误: from bs4 import BeautifulSoup page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY') soup = Bea

我已经使用
'pip install requests'
安装了请求,但我没有得到任何回报

我正在按照basic中给出的示例进行操作,并在
code
上不断得到这个
错误:

from bs4 import BeautifulSoup
page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY')
soup = BeautifulSoup(page.content, 'html-parser')
print(soup)
以及
错误

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-90e58007c1ee> in <module>
      1 from bs4 import BeautifulSoup
----> 2 page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY')
      3 soup = BeautifulSoup(page.content, 'html-parser')
      4 print(soup)

NameError: name 'requests' is not defined
---------------------------------------------------------------------------
NameError回溯(最近一次呼叫上次)
在里面
1来自bs4进口美化集团
---->2页=请求。获取('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.2956399999999#.Xq3cLZl7lPY')
3 soup=BeautifulSoup(page.content,“html解析器”)
4印刷品(汤)
NameError:未定义名称“请求”

我认为,您需要导入请求。你可以试试:

from bs4 import BeautifulSoup
import requests
page = requests.get('https://forecast.weather.gov/MapClick.php?lat=47.19044000000008&lon=-122.29563999999999#.Xq3cLZl7lPY')
soup = BeautifulSoup(page.text, 'lxml')
print(soup)

您的代码顶部是否有
import requests
语句<代码>pip安装请求
在您的计算机上安装程序包,但随后您需要在代码中使用导入语句。错误为“未定义”和“未找到”。你确定要导入请求吗?这成功了!我不太熟悉使用库。有没有好的教程可以帮助您更熟悉它们的使用?