问题产生
在进行爬虫抓取时,需要安装第三方模块库BeautifulSoup。
探索过程
尝试使用pip install BeautifulSoup
问题一:
SyntaxError: Missing parentheses in call to ‘print’. Did you mean print(int “Unit tests have failed!”)?
方法一:
进入官网下载安装包https://files.pythonhosted.org/packages/1e/ee/295988deca1a5a7accd783d0dfe14524867e31abb05b6c0eeceee49c759d/BeautifulSoup-3.2.1.tar.gz
解压后再次键入:python install setup.py
PS使用wheel安装包时:pip install **.whl
但依旧发现安装失败。
此时在源代码文件setup.py:阅读后发现其print未使用函数
from distutils.core import setup
import unittest
import warnings
warnings.filterwarnings("ignore", "U

在Python网络爬虫中遇到安装BeautifulSoup4时失败,出现SyntaxError,尝试从官网下载安装包并手动安装,但依然失败。问题源于Python 2到3的语法变化,print需要作为函数使用。经验证,Python 3.7版本可以成功安装BS4。注意在IDLE中导入时不能使用'BeautifulSoup4',需使用'bs4'。建议使用Python 2.7.7或考虑使用BS3以适应Python3。
最低0.47元/天 解锁文章
1453

被折叠的 条评论
为什么被折叠?



