質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Scrapy

Scrapyは、Pythonで開発されたオープンソースソフトウェアです。スクレイピングという、Webサービスから必要な情報を取り出したり自動操作をしたりする技術を使うものです。

Q&A

解決済

4回答

2112閲覧

Python3でscrapyのインストールに失敗します。

noripi

総合スコア34

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Scrapy

Scrapyは、Pythonで開発されたオープンソースソフトウェアです。スクレイピングという、Webサービスから必要な情報を取り出したり自動操作をしたりする技術を使うものです。

0グッド

1クリップ

投稿2017/03/22 07:25

環境は
CentOS6系でPython3.5.3です。
pipでscrapyをインストールしようとすると下記エラーとなります。
gcc gcc-c++ kernel-devel libffi-devel python-devel openssl-devel libxslt-devel openssl pyOpenSSL
などを入れてみたり、色々検索して試してみたのですが一向に解決しないので、投稿いたしました。
全ては載せきれなかったので怪しそうな部分を載せます。
大変恐縮ですが、初心者にもわかりやすく解説して頂ければ幸いです。

running egg_info writing src/cryptography.egg-info/PKG-INFO writing entry points to src/cryptography.egg-info/entry_points.txt writing requirements to src/cryptography.egg-info/requires.txt writing dependency_links to src/cryptography.egg-info/dependency_links.txt writing top-level names to src/cryptography.egg-info/top_level.txt reading manifest file 'src/cryptography.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'docs/_build' warning: no previously-included files matching '*' found under directory 'vectors' writing manifest file 'src/cryptography.egg-info/SOURCES.txt' running build_ext generating cffi module 'build/temp.linux-x86_64-3.5/_padding.c' creating build/temp.linux-x86_64-3.5 generating cffi module 'build/temp.linux-x86_64-3.5/_constant_time.c' generating cffi module 'build/temp.linux-x86_64-3.5/_openssl.c' building '_openssl' extension creating build/temp.linux-x86_64-3.5/build creating build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5 gcc -pthread -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.5m -c build/temp.linux-x86_64-3.5/_openssl.c -o build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5/_openssl.o build/temp.linux-x86_64-3.5/_openssl.c:12:24: error: pyconfig.h: そのようなファイルやディレクトリはありません build/temp.linux-x86_64-3.5/_openssl.c:18:20: error: Python.h: そのようなファイルやディレクトリはありません build/temp.linux-x86_64-3.5/_openssl.c:363: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token build/temp.linux-x86_64-3.5/_openssl.c:713:22: error: pythread.h: そのようなファイルやディレクトリはありません build/temp.linux-x86_64-3.5/_openssl.c: In function ‘dev_urandom_fd’: build/temp.linux-x86_64-3.5/_openssl.c:2538: 警告: implicit declaration of function ‘fstat’ build/temp.linux-x86_64-3.5/_openssl.c: トップレベル: build/temp.linux-x86_64-3.5/_openssl.c:3554: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token build/temp.linux-x86_64-3.5/_openssl.c: In function ‘_ssl_thread_locking_function’: build/temp.linux-x86_64-3.5/_openssl.c:3572: error: ‘_ssl_locks’ undeclared (first use in this function) build/temp.linux-x86_64-3.5/_openssl.c:3572: error: (Each undeclared identifier is reported only once build/temp.linux-x86_64-3.5/_openssl.c:3572: error: for each function it appears in.) build/temp.linux-x86_64-3.5/_openssl.c:3578: 警告: implicit declaration of function ‘PyThread_acquire_lock’ build/temp.linux-x86_64-3.5/_openssl.c:3580: 警告: implicit declaration of function ‘PyThread_release_lock’ build/temp.linux-x86_64-3.5/_openssl.c: In function ‘_setup_ssl_threads’: build/temp.linux-x86_64-3.5/_openssl.c:3587: error: ‘_ssl_locks’ undeclared (first use in this function) build/temp.linux-x86_64-3.5/_openssl.c:3589: 警告: implicit declaration of function ‘PyMem_New’ build/temp.linux-x86_64-3.5/_openssl.c:3589: error: ‘PyThread_type_lock’ undeclared (first use in this function) build/temp.linux-x86_64-3.5/_openssl.c:3591: 警告: implicit declaration of function ‘PyErr_NoMemory’ build/temp.linux-x86_64-3.5/_openssl.c:3596: 警告: implicit declaration of function ‘PyThread_allocate_lock’ build/temp.linux-x86_64-3.5/_openssl.c:3600: 警告: implicit declaration of function ‘PyThread_free_lock’ build/temp.linux-x86_64-3.5/_openssl.c:3602: 警告: implicit declaration of function ‘PyMem_Free’ build/temp.linux-x86_64-3.5/_openssl.c: トップレベル: build/temp.linux-x86_64-3.5/_openssl.c:12998: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token build/temp.linux-x86_64-3.5/_openssl.c:13034: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token build/temp.linux-x86_64-3.5/_openssl.c:13058: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token .....(上記の数字違いが数十行) build/temp.linux-x86_64-3.5/_openssl.c:70617: error: ‘_cffi_f_ASN1_IA5STRING_new’ undeclared here (not in a function) build/temp.linux-x86_64-3.5/_openssl.c:70618: error: ‘_cffi_f_ASN1_INTEGER_cmp’ undeclared here (not in a function) build/temp.linux-x86_64-3.5/_openssl.c:70619: error: ‘_cffi_f_ASN1_INTEGER_dup’ undeclared here (not in a function) .....(上記の数字違いが数十行) build/temp.linux-x86_64-3.5/_openssl.c:73317: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘init_openssl’ error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2uh6etal/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-p1x27bcm-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-2uh6etal/cryptography/

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答4

0

ベストアンサー

yumで「python35u」をインストールしているのであれば、以下のパッケージを
利用するのではないでしょうか。

yum install python35u-devel

投稿2017/03/23 14:26

gorogoroIT

総合スコア447

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

noripi

2017/03/24 00:26

ご回答ありがとうございます。 一旦すべてremove後、python35u-develを含めて再インストールした結果、scrapyのインストールに成功しました。 おそらく、removeしなくてもpython35u-develのインストールで成功したと思います。 ありがとうございます。
guest

0

Failed to install Python Cryptography package with PIP and setup.pyによると、まずは以下を試してみるのもよいかと思います。
sudo yum install gcc libffi-devel python-devel openssl-devel
openssl-develのみでもよさそうですが。

投稿2017/03/23 14:18

can110

総合スコア38234

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

can110

2017/03/23 14:33

確認不足でした。tell_kさんと同じ内容です。こちらの回答は無視してください。
noripi

2017/03/24 00:21

ご回答ありがとうございます。了解しました。
guest

0

エラーを見る限り、cryptography という Scrapy が依存してるライブラリのインストールに失敗しているようです。

http://stackoverflow.com/a/22210069/7724457

上記参考URLを見る限り必要な yumパッケージは gcc libffi-devel python-devel openssl-devel で、既にインストールされてるものの中に全て含まれているようです。

一応確認のために sudo yum list installed でちゃんとインストールされているか確認してみてください。もし何か足りないようであれば、下記の手順でもう一度 cryptography をインストールしてみてください。

shell

1$ sudo yum install gcc libffi-devel python-devel openssl-devel 2$ pip cryptography

それでもダメなようであれば、 terapyon さんの仰るとおり、仮にソースからビルドしてPythonをインストールしているのであれば、リビルドが必要になるかもしれません。

投稿2017/03/22 17:40

tell_k

総合スコア2120

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

noripi

2017/03/23 15:15

ご回答ありがとうございます。 検証してみます。
guest

0

Python3.5.3 はどのようにインストールされていますか?

コンパイルしているとしたら、 yum 関連モジュールインストール後(ここでは、openssl-develだと思いますが)に、Python3.5.3 のリビルドが必要になります。

もう1度Pythonのコンパイルから行ってみてください。

投稿2017/03/22 10:16

terapyon

総合スコア313

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

noripi

2017/03/23 14:11

回答が遅くなり申し訳ありません。 python3は、yumのiusリポジトリを利用してpython35uでインストールしました。 一度、removeしてもう一度インストールということでよろしいでしょうか。
terapyon

2017/03/24 00:59

元々は、ソースからコンパイルしたものを使っていたのではないでしょうか? それを想定して、リビルドが必要というアドバイスをしました。
noripi

2017/03/24 01:25

申し訳ありません。私の説明不足です。 pythonとpipはyumにiusリポジトリを追加して、yumからインストールを行いました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問