[英]ModuleNotFoundError: No module named 'scrapy' for MAC OSX
Using Python Version 2.7.10 I downloaded Scrapy and on Version 1.4.0 I'm questioning where exactly I need to have these installed? 使用Python 2.7.10版,我下载了Scrapy,在1.4.0版上,我在问到底需要在哪里安装这些工具? I changed my filename from scrapy.py to scrapy123.py to no avail.
我将文件名从scrapy.py更改为scrapy123.py无济于事。 I'm frustrated!
我很沮丧! ha
哈
Receiving the infamous error of: 收到以下臭名昭著的错误:
Traceback (most recent call last):
File "/Users/william/PycharmProjects/scrapy123.py", line 1, in <module>
import scrapy
ModuleNotFoundError: No module named 'scrapy'
Script: 脚本:
import scrapy
class BlogSpider(scrapy.Spider):
name = 'blogspider'
start_urls = ['https://blog.scrapinghub.com']
def parse(self, response):
for title in response.css('h2.entry-title'):
yield {'title': title.css('a ::text').extract_first()}
next_page = response.css('div.prev-post > a
::attr(href)').extract_first()
if next_page:
yield scrapy.Request(response.urljoin(next_page),
callback=self.parse)
using the pep-0328 __future__
absolute_import
helps to make this less ambiguous and has been supported from 2.5. 使用pep-0328
__future__
absolute_import
有助于减少歧义,并且从2.5开始受到支持。
from __future__ import absolute_import
Then you can simply import .scrappy
and make sure it is loading the version expected. 然后,您只需
import .scrappy
并确保它正在加载预期的版本。 It will also help when moving to Python3 移至Python3时也有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.