Pythonとlinux初心者が治療を開始しようとしています。 https://doc.scrapy.org/en/latest/intro/tutorial.htmlの指示とコードに従ってください。ユーザーの警告を受け取っています "service_identityモジュールのインストールがありません: '名前を取り込めません。' opentype 'Python Scrapy - service_identity(opentype)が動作しておらず、インストールできない
「service_identity」をインストールしようとしましたが、インストールのさまざまな部分で「Requirment already satisfied」両方のPIP3とダウンロードを試み、以下は、PyPI-URLからダウンロードし.whlたファイルからインストールしてください。
のpython 3.5.3をlubuntu 17.04上のVirtualBoxに
[email protected]:~$ scrapy startproject tutorial2
:0: UserWarning: You do not have a working installation of the service_identity module: 'cannot import name 'opentype''. Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
New Scrapy project 'tutorial2', using template directory '/usr/local/lib/python3.5/dist-packages/scrapy/templates/project', created in:
/home/mat/tutorial2
You can start your first spider with:
cd tutorial2
scrapy genspider example example.com
[email protected]:~$ pip3 install Downloads/
geckodriver-v0.19.1-linux64.tar.gz
NOOBS_lite_v2_4.zip
npm-debug.log
phantomjs-2.1.1-linux-x86_64/
phantomjs-2.1.1-linux-x86_64.tar.bz2
reveal.js-master.zip
service_identity/
service_identity-17.0.0.dist-info/
service_identity-17.0.0-py2.py3-none-any.whl
[email protected]:~$ pip3 install Downloads/service_identity-17.0.0
Invalid requirement: 'Downloads/service_identity-17.0.0'
It looks like a path. Does it exist ?
[email protected]:~$ pip3 install Downloads/service_identity-17.0.0-py2.py3-none-any.whl
Requirement already satisfied: service-identity==17.0.0 from file:///home/mat/Downloads/service_identity-17.0.0-py2.py3-none-any.whl in /usr/local/lib/python3.5/dist-packages
Requirement already satisfied: pyopenssl>=0.12 in /usr/local/lib/python3.5/dist-packages (from service-identity==17.0.0)
Requirement already satisfied: attrs in /usr/local/lib/python3.5/dist-packages (from service-identity==17.0.0)
Requirement already satisfied: pyasn1-modules in /usr/local/lib/python3.5/dist-packages (from service-identity==17.0.0)
Requirement already satisfied: pyasn1 in /usr/lib/python3/dist-packages (from service-identity==17.0.0)
Requirement already satisfied: six>=1.5.2 in /usr/lib/python3/dist-packages (from pyopenssl>=0.12->service-identity==17.0.0)
Requirement already satisfied: cryptography>=2.1.4 in /usr/local/lib/python3.5/dist-packages (from pyopenssl>=0.12->service-identity==17.0.0)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/local/lib/python3.5/dist-packages (from cryptography>=2.1.4->pyopenssl>=0.12->service-identity==17.0.0)
Requirement already satisfied: cffi>=1.7; platform_python_implementation != "PyPy" in /usr/local/lib/python3.5/dist-packages (from cryptography>=2.1.4->pyopenssl>=0.12->service-identity==17.0.0)
Requirement already satisfied: idna>=2.1 in /usr/lib/python3/dist-packages (from cryptography>=2.1.4->pyopenssl>=0.12->service-identity==17.0.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.5/dist-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=2.1.4->pyopenssl>=0.12->service-identity==17.0.0)
[email protected]:~$
をhappesものを見るために、とにかくしよう
私/home/mat/tutorial2/tutorial2/spiders/qoutes_spider.pyでコード
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
def start_requests(self):
urls = [
'http://quotes.toscrape.com/page/1/',
'http://quotes.toscrape.com/page/2/',
]
for url in urls:
yield scrapy.Request(url=url, callback=self.parse)
def parse(self, response):
page = response.url.split("/")[-2]
filename = 'quotes-%s.html' % page
with open(filename, 'wb') as f:
f.write(response.body)
self.log('Saved file %s' % filename)
sudoでroot/adminとしてインストールしようとしましたか? – furas
あなたは 'OpenSSL'を最初にインストールする必要があるかもしれません - [このページ](https://pypi.python.org/pypi/service_identity)は' service_identity'が 'OpenSSL'を必要とするかもしれない' pyOpenSSL'を使っていることを示していますあなたは 'apt'でインストールする必要があります) – furas