爬虫常见错误及解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/carson0408/article/details/90041638

        在爬虫或者安装框架过程中,会碰到一些报错或者问题,本文主要对这些问题进行收集整理。

1.ERROR: No matching distribution found for win32api

解决方法:折是缺少win32api模块,这里需要安装pypiwin32库,安装命令:pip install pypiwin32

2.pycharm安装库时出现AttributeError: module 'pip' has no attribute 'main'

找到pycharm安装目录下的\helpers\packaging_tool.py,打开文件,将文件中与下面注释部分一致的代码注释,然后添加如下非注释代码。

"""
def do_install(pkgs):
    try:
        import pip
    except ImportError:
        error_no_pip()
    return pip.main(['install'] + pkgs)


def do_uninstall(pkgs):
    try:
        import pip
    except ImportError:
        error_no_pip()
    return pip.main(['uninstall', '-y'] + pkgs)"""

def do_install(pkgs):
    try:
        #import pip
        try:
            from pip._internal import main
        except Exception:
            from pip import main
    except ImportError:
        error_no_pip()
    #return pip.main(['install'] + pkgs)
    return main(['install'] + pkgs)
 
 
def do_uninstall(pkgs):
    try:
        #import pip
        try:
            from pip._internal import main
        except Exception:
            from pip import main
    except ImportError:
        error_no_pip()
    #return pip.main(['uninstall', '-y'] + pkgs)
    return main(['uninstall', '-y'] + pkgs)

3.如何较好的安装scrapy

        需要先安装依赖包,要先安装twisted等依赖包,如下图所示,从下往上依次安装依赖包,最后安装scrapy。一般可以直接使用pip install 名字命令直接安装,或者在https://download.lfd.uci.edu/pythonlibs/q5gtlas7/Twisted-19.2.0-cp35-cp35m-win32.whl地址下载相应文件,然后用pip install 文件名(包含扩展名)来安装,由于是whl文件,要先利用pip install  wheel安装wheel。

猜你喜欢

转载自blog.csdn.net/carson0408/article/details/90041638