Python 我一直在获取modulenofounderror:没有名为';bs4和x27;错误
我正在尝试为一个网站编写一个解析器,因为我需要这个网站的所有内容。以下是我目前的代码:Python 我一直在获取modulenofounderror:没有名为';bs4和x27;错误,python,python-3.x,Python,Python 3.x,我正在尝试为一个网站编写一个解析器,因为我需要这个网站的所有内容。以下是我目前的代码: import urllib.request from bs4 import BeauitfulSoup def get_html(url): response = urllib.request.urlopen(url) return response.read() def main(): print(get_html('http://marryme.md')) if __name
import urllib.request
from bs4 import BeauitfulSoup
def get_html(url):
response = urllib.request.urlopen(url)
return response.read()
def main():
print(get_html('http://marryme.md'))
if __name__ == '__main__':
main()
我已经在虚拟环境中安装了bs4,并且在我的pip列表中看到已成功安装。我还在我的
virtualenv
目录中找到了bs4文件夹,但是当我运行代码时,我一直收到这个错误 您需要首先激活virtualenv:
. venv/bin/activate
python script.py
或者显式指定Python解释器:
venv/bin/python script.py
当然,请将
venv
替换为您的virtualenv的名称/路径。pip3安装beautifulsoup4
?…请提供更多详细信息。bs4文件夹在virtualenv目录中的确切位置?如何运行脚本?有蛇帮线吗?什么线?