ScrapyでクローリングとスクレイピングしようとしたらOpensslで引っかかった話
$ scrapy crawl [プロジェクト名]
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 6, in <module>
from scrapy.cmdline import execute
File "/usr/local/lib/python3.7/site-packages/scrapy/cmdline.py", line 9, in <module>
from scrapy.crawler import CrawlerProcess
File "/usr/local/lib/python3.7/site-packages/scrapy/crawler.py", line 18, in <module>
from scrapy.core.engine import ExecutionEngine
File "/usr/local/lib/python3.7/site-packages/scrapy/core/engine.py", line 14, in <module>
from scrapy.core.scraper import Scraper
File "/usr/local/lib/python3.7/site-packages/scrapy/core/scraper.py", line 13, in <module>
from scrapy.utils.log import logformatter_adapter, failure_to_exc_info
File "/usr/local/lib/python3.7/site-packages/scrapy/utils/log.py", line 14, in <module>
from scrapy.utils.versions import scrapy_components_versions
File "/usr/local/lib/python3.7/site-packages/scrapy/utils/versions.py", line 12, in <module>
from scrapy.utils.ssl import get_openssl_version
File "/usr/local/lib/python3.7/site-packages/scrapy/utils/ssl.py", line 3, in <module>
import OpenSSL
File "/usr/local/lib/python3.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/local/lib/python3.7/site-packages/OpenSSL/crypto.py", line 15, in <module>
from OpenSSL._util import (
File "/usr/local/lib/python3.7/site-packages/OpenSSL/_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 203, in <module>
Binding.init_static_locks()
File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 143, in init_static_locks
__import__("_ssl")
ImportError: dlopen(/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so
Reason: image not found
OpenSSLでつまずいているよう。とりあえず。更新しようと言うことで、、、
brew install openssl
scrapyを再実行しても結果は変わらず。そこで、インストールされたOpensslのバージョンを調べて使ってくれるように変更すればなんとかなるかなと思い下のコマンドを実行。
$ openssl version
OpenSSL 1.1.1g 21 Apr 2020
$ brew switch openssl 1.1.1g
Error: openssl does not have a version "1.1.1g" in the Cellar.
openssl's installed versions: 1.0.2r
$ brew switch openssl 1.0.2r
Cleaning /usr/local/Cellar/openssl/1.0.2r
Opt link created for /usr/local/Cellar/openssl/1.0.2r
最初にopensslのバージョン確認1.1.1gというバージョンがインストールされているのでbrewを使って1.1.1gを使うようにswitchしようとすると1.0.2rがインストールされているとのこと(なんでやねん!)仕方ないので言われるがまま1.0.2rにswitch。
なんかスコッと行けたみたい。
scrapyのcrawlコマンド使うと普通に 通った!!
ディスカッション
コメント一覧
まだ、コメントがありません