python3.6安装scrapy出错_请教安装 Scrapy 时的这个错误如何解决

32 位的 WINDOWS7,PYTHON3.6 环境下要安装 Scrapy-1.4.0-py2.py3-none-any.whl ,这个 whl 文件已经下载并放到 python 目录下,输入命令为 pip install Scrapy-1.4.0-py2.py3-none-any.whl

安装了很多包后,出现了以下的出错提示,请问这是什么原因导致的,如何解决呢?感谢指点!

Requirement already satisfied: pyparsing in d:\python\python3\lib\site-packages (from packaging>=16.8->setuptools->zope.interfac

e>=4.0.2->Twisted>=13.1.0->Scrapy==1.4.0)

Installing collected packages: Twisted, Scrapy

Running setup.py install for Twisted ... error

Exception:

Traceback (most recent call last):

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\compat\__init__.py", line 73, in console_to_str

return s.decode(sys.__stdout__.encoding)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\commands\install.py", line 342, in run

prefix=options.prefix_path,

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\req\req_set.py", line 784, in install

**kwargs

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\req\req_install.py", line 878, in install

spinner=spinner,

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\__init__.py", line 676, in call_subprocess

line = console_to_str(proc.stdout.readline())

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\compat\__init__.py", line 75, in console_to_str

return s.decode('utf_8')

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\commands\install.py", line 385, in run

requirement_set.cleanup_files()

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\req\req_set.py", line 729, in cleanup_files

req.remove_temporary_source()

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\req\req_install.py", line 977, in remove_temporary_source

rmtree(self.source_dir)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f

return Retrying(*dargs, **dkw).call(f, *args, **kw)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 212, in call

raise attempt.get()

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 247, in get

six.reraise(self.value[0], self.value[1], self.value[2])

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\six.py", line 686, in reraise

raise value

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 200, in call

attempt = Attempt(fn(*args, **kwargs), attempt_number, False)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\__init__.py", line 102, in rmtree

οnerrοr=rmtree_errorhandler)

File "d:\python\python3\lib\shutil.py", line 494, in rmtree

return _rmtree_unsafe(path, onerror)

File "d:\python\python3\lib\shutil.py", line 384, in _rmtree_unsafe

_rmtree_unsafe(fullname, onerror)

File "d:\python\python3\lib\shutil.py", line 384, in _rmtree_unsafe

_rmtree_unsafe(fullname, onerror)

File "d:\python\python3\lib\shutil.py", line 384, in _rmtree_unsafe

_rmtree_unsafe(fullname, onerror)

[Previous line repeated 1 more times]

File "d:\python\python3\lib\shutil.py", line 389, in _rmtree_unsafe

onerror(os.unlink, fullname, sys.exc_info())

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler

func(path)

Permissi onError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'c:\\TEMP\\pip-build-n_4iqc5q\\Twisted\\src\\twisted\\i

nternet\\iocpreactor\\iocpsupport\\iocpsupport.c'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\basecommand.py", line 215, in main

status = self.run(options, args)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\commands\install.py", line 385, in run

requirement_set.cleanup_files()

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\build.py", line 38, in __exit__

self.cleanup()

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\build.py", line 42, in cleanup

rmtree(self.name)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f

return Retrying(*dargs, **dkw).call(f, *args, **kw)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 212, in call

raise attempt.get()

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 247, in get

six.reraise(self.value[0], self.value[1], self.value[2])

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\six.py", line 686, in reraise

raise value

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\retrying.py", line 200, in call

attempt = Attempt(fn(*args, **kwargs), attempt_number, False)

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\__init__.py", line 102, in rmtree

οnerrοr=rmtree_errorhandler)

File "d:\python\python3\lib\shutil.py", line 494, in rmtree

return _rmtree_unsafe(path, onerror)

File "d:\python\python3\lib\shutil.py", line 384, in _rmtree_unsafe

_rmtree_unsafe(fullname, onerror)

File "d:\python\python3\lib\shutil.py", line 384, in _rmtree_unsafe

_rmtree_unsafe(fullname, onerror)

File "d:\python\python3\lib\shutil.py", line 384, in _rmtree_unsafe

_rmtree_unsafe(fullname, onerror)

[Previous line repeated 2 more times]

File "d:\python\python3\lib\shutil.py", line 389, in _rmtree_unsafe

onerror(os.unlink, fullname, sys.exc_info())

File "C:\Users\YY\AppData\Roaming\Python\Python36\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler

func(path)

Permissi onError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'c:\\TEMP\\pip-build-n_4iqc5q\\Twisted\\src\\twisted\\i

nternet\\iocpreactor\\iocpsupport\\iocpsupport.c'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Scrapy是一个基于Python的爬虫框架,它可以帮助我们快速高效地抓取网站数据。在这里,我将介绍Scrapy的基本用法,让您能够快速入门。 安装Scrapy ----------------------- 在安装Scrapy之前,我们需要先安装Python。然后,我们可以通过以下命令来安装Scrapy: ``` pip install scrapy ``` 创建Scrapy项目 ----------------------- 创建Scrapy项目的命令是: ``` scrapy startproject project_name ``` 这个命令将会在当前目录下创建一个名为project_name的文件夹,其中包含了Scrapy项目的基本结构。 编写Spider ----------------------- 在Scrapy中,Spider是用来定义爬取网站的规则的。我们可以通过以下命令来创建一个Spider: ``` scrapy genspider spider_name domain_name ``` 其中,spider_name是我们自己定义的Spider名称,domain_name是我们要抓取的网站域名。 接下来,我们需要在Spider中定义如何爬取网站。这里我们以爬取“http://quotes.toscrape.com/”网站上的名言警句为例。我们可以在Spider中定义如下规则: ```python import scrapy class QuotesSpider(scrapy.Spider): name = "quotes" start_urls = [ 'http://quotes.toscrape.com/page/1/', 'http://quotes.toscrape.com/page/2/', ] def parse(self, response): for quote in response.css('div.quote'): yield { 'text': quote.css('span.text::text').get(), 'author': quote.css('span small::text').get(), 'tags': quote.css('div.tags a.tag::text').getall(), } next_page = response.css('li.next a::attr(href)').get() if next_page is not None: yield response.follow(next_page, self.parse) ``` 在上述代码中,我们首先定义了Spider的名称,接着定义了我们要爬取的起始URL,最后定义了如何解析网页的函数parse()。在parse()函数中,我们使用了Scrapy的选择器来提取网页中的名言警句,并将其保存到字典中。接着,我们使用response.follow()函数来获取下一页的URL,并继续解析。 运行Spider ----------------------- 要运行我们刚才创建的Spider,我们可以使用以下命令: ``` scrapy crawl spider_name ``` 其中,spider_name是我们之前创建的Spider名称。 Scrapy会自动去抓取我们定义的起始URL,并根据我们定义的规则来解析网页。解析完成后,Scrapy会将结果保存到我们指定的位置。 总结 ----------------------- Scrapy是一个非常强大的Python爬虫框架,它可以帮助我们快速高效地抓取网站数据。在本教程中,我们介绍了Scrapy项目的创建、Spider的定义以及如何运行Spider。如果您想更深入地学习Scrapy,可以参考官方文档:https://docs.scrapy.org/en/latest/。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值