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

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

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

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

5161閲覧

プロキシを通したライブラリ(PyAutoGUI)のインストール

YuYuto

総合スコア1

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/06/17 13:45

前提・実現したいこと

Pythonを勉強し始めて1か月程度の初心者です。他にプログラミング経験はありません。
PyAutoGUIライブラリをコマンドプロンプトにてインストールしようとしているのですが、うまくいきません。
会社でプロキシがあるので、プロキシがある状態でのインストール方法を調べて試しましたができず、
オフラインでもインストールしてみましたができませんでした。
エラー等を見る限りPyAutoGUIをインストールする場合はオンラインが必要な感じがします。
どうしたらインストールできますか?
プロキシのセットや書き方が何か間違っているのでしょうか?

ご教示よろしくお願いいたします。

発生している問題・エラーメッセージ

⓵ C:\Users******>py -m pip install pyautogui --proxy http://[ID]:[PASS]@proxy2.*********:8080 Collecting pyautogui WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pyautogui/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pyautogui/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pyautogui/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pyautogui/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))': /simple/pyautogui/ Could not fetch URL https://pypi.org/simple/pyautogui/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pyautogui/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))) - skipping ERROR: Could not find a version that satisfies the requirement pyautogui (from versions: none) ERROR: No matching distribution found for pyautogui Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))) - skippingSSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))) - skipping ⓶ C:\Users******>set HTTP_PROXY=http://[ID]:[PASS]@proxy2.*********:8080 C:\Users******>py -m pip install pyautogui Collecting pyautogui WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x042E98B0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x042E99D0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x042E9B80>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x042E9328>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0432A040>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui/ ERROR: Could not find a version that satisfies the requirement pyautogui (from versions: none) ERROR: No matching distribution found for pyautogui ⓷ C:\Users******>cd Documents C:\Users******\Documents>py -m pip install --no-index --find-links=pyautogui_src pyautogui Looking in links: pyautogui_src Collecting pyautogui Collecting pymsgbox (from pyautogui) Installing build dependencies ... error ERROR: Command errored out with exit status 1: command: 'C:\Users******\AppData\Local\Programs\Python\Python38-32\python.exe' 'C:\Users******\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users******\AppData\Local\Temp\pip-build-env-sxmby76v\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: --no-index --find-links pyautogui_src -- 'setuptools>=40.8.0' wheel cwd: None Complete output (4 lines): Looking in links: pyautogui_src Collecting setuptools>=40.8.0 ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none) ERROR: No matching distribution found for setuptools>=40.8.0 ---------------------------------------- ERROR: Command errored out with exit status 1: 'C:\Users******\AppData\Local\Programs\Python\Python38-32\python.exe' 'C:\Users******\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users******\AppData\Local\Temp\pip-build-env-sxmby76v\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: --no-index --find-links pyautogui_src -- 'setuptools>=40.8.0' wheel Check the logs for full command output. ⓸ C:\Users******\Documents>py -m pip install pyautogui_src Collecting pyautogui_src WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04429838>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui-src/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04429460>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui-src/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04429B98>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui-src/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04429628>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui-src/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x04429AA8>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/pyautogui-src/ ERROR: Could not find a version that satisfies the requirement pyautogui_src (from versions: none) ERROR: No matching distribution found for pyautogui_src ⓹ C:\Users******>cd Documents\pyautogui_src C:\Users******\Documents\pyautogui_src>py -m pip install PyAutoGUI-0.9.50.tar.gz Processing c:\users******\documents\pyautogui_src\pyautogui-0.9.50.tar.gz Collecting pymsgbox (from PyAutoGUI==0.9.50) WARNING: --------字数制限の為短縮 ⓸と同一エラー繰り返し-------- ERROR: Could not find a version that satisfies the requirement pymsgbox (from PyAutoGUI==0.9.50) (from versions: none) ERROR: No matching distribution found for pymsgbox (from PyAutoGUI==0.9.50)

該当のソースコード

Python

12py -m pip install pyautogui --proxy http://[ID]:[PASS]@proxy2.*********:8080 3 45set HTTP_PROXY=http://[ID]:[PASS]@proxy2.*********:8080 6py -m pip install pyautogui 7 89C:\Users******>cd Documents 10C:\Users******\Documents>py -m pip install --no-index --find-links=pyautogui_src pyautogui 11 1213C:\Users******\Documents>py -m pip install pyautogui_src 14 1516C:\Users******>cd Documents\pyautogui_src 17C:\Users******\Documents\pyautogui_src>py -m pip install PyAutoGUI-0.9.50.tar.gz

試したこと

以上のようにいろいろ試していますがインストールできておりません。
プロキシはPACを開いて一番下の行にあった複数(proxy2,3,4)を試しましたができませんでした。
⓷~⓹のように、オフラインでインストールしてもエラーが出ます。
パッケージの中を1つ1つオフラインでインストールした場合(⓹)、
PyAutoGUIとPyMsgBoxだけインストールできませんでした。

補足情報(FW/ツールのバージョンなど)

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32

Package Version


et-xmlfile 1.0.1
jdcal 1.4.1
MouseInfo 0.1.3
openpyxl 3.0.3
Pillow 7.1.2
pip 19.2.3
PyGetWindow 0.0.8
pyperclip 1.8.0
PyRect 0.1.4
PyScreeze 0.1.26
PyTweening 1.0.3
selenium 3.141.0
setuptools 41.2.0
urllib3 1.25.9

今までインストールした物はとりあえずオフラインで入れています。

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

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

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

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

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

hentaiman

2020/06/17 14:55

会社の人に聞いた方が良いよ ちょっと出来る中級程度の人じゃなくてちゃんと上位の技術レベル持ってる人
meg_

2020/06/17 22:11 編集

私の場合は環境変数をセットすればプロキシ対応出来ました。httpsについても設定してみてください。
YuYuto

2020/06/18 04:56

無事解決しました。ありがとうございました。
guest

回答1

0

ベストアンサー

原因

(1)のログから抜粋。

Could not fetch URL https://pypi.org/simple/pyautogui/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pyautogui/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1108)'))) - skipping

self signed certificate(自己署名証明書)により証明書の認証に失敗している、ということです。
おそらく自PC~プロキシ間の通信にプロキシ自身が発行した自己署名証明書を使用しているのでしょう。

対策

1つは、pip時に--trusted-hostオプションをセットすること。指定のホストへの通信に対し、証明書のエラーを無視してくれます。
今回はpypi.orgに対しての通信なので、py -m pip install pyautogui --trusted-host pypi.org --proxy http://[ID]:[PASS]@proxy2.*********:8080のように指定することで証明書のエラーを回避できます(できないかもしれません)

もう一つの対策は、質問者が(5)で行った通りオフラインでインストールすることですが、依存関係にあるパッケージがインストールされていないと失敗します。
本件の場合はpymsgboxを先にインストールする必要があるので、PyAutoGUIのアーカイブを取得したようにpymsgboxのアーカイブを別途取得し、同じようにインストールしてやれば良いでしょう。
さらに依存関係がある場合も同様に順番に解決していけば大丈夫だと思います。

参考:pipでインストール時にエラーが出力される

投稿2020/06/17 14:46

hope_mucci

総合スコア4447

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

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

YuYuto

2020/06/18 04:52 編集

ご回答ありがとうございました。 お陰様で無事に解決することができました! pypi.orgだけでは上手くいかず、ご紹介いただいたページの “--trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org” をそのまま使ったところ、インストールできました。 かなり悩んでいたのでとても嬉しいです。 本当にありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問