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

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

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

OpenSSLはSSL/TLSのプロトコルと一般的な暗号のライブラリを導入するオープンソースのソフトウェアのツールキットです。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Python

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

pip

pipとは、Pythonを用いて書かれているパッケージソフトのインストールや管理を行うためのパッケージマネジメントシステムです。pipを使う主なメリットは、コマンドラインインターフェースにて容易にPythonパッケージソフトをインストール可能だという点です。

Q&A

2回答

2850閲覧

Python 仮想環境下でpip install requests とするとエラーが出る

yuda

総合スコア5

OpenSSL

OpenSSLはSSL/TLSのプロトコルと一般的な暗号のライブラリを導入するオープンソースのソフトウェアのツールキットです。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Python

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

pip

pipとは、Pythonを用いて書かれているパッケージソフトのインストールや管理を行うためのパッケージマネジメントシステムです。pipを使う主なメリットは、コマンドラインインターフェースにて容易にPythonパッケージソフトをインストール可能だという点です。

0グッド

0クリップ

投稿2019/12/08 05:32

編集2019/12/08 06:12

前提・実現したいこと

macos上にて
python3 -m venv 名前
として仮想環境を立ち上げ、仮想環境内で
pip install requests
をしたいのですがSSLエラーが出ます。

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

以下 sudo pip install requests を行ったエラーです

Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping Could not find a version that satisfies the requirement requests (from versions: ) No matching distribution found for requests pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. 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("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

試したこと

brew install openssl

下記エラーです
Warning: openssl@1.1 1.1.1d is already installed and up-to-date
To reinstall 1.1.1d, run brew reinstall openssl@1.1

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

Python 3.7.2

pip 18.1
scraping/lib/python3.7/site-packages/pip (python 3.7)

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

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

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

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

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

kazto

2019/12/08 08:01

pythonはどのようにしてインストールしましたか?
yuda

2019/12/13 04:30

おそらくmac備え付けのものか、 brew install python だと思います。。 曖昧で申し訳ありません。
yuda

2019/12/13 05:03 編集

(scraping) 名前noMacBook-puro:crawling_and_scraping 名前$ which python /Users/名前/Desktop/python_work/crawling_and_scraping/scraping/bin/python 上記のpythonを参照しているみたいです。
guest

回答2

0

おそらくpip/pythonが古いopenssl(1.0.2s)を参照しているのではありませんか? 情報を見る限り、質問者の方のopensslは最新版になっているので参照エラーが起きているように思います

python

1import ssl
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/[username]/.pyenv/versions/3.7.0/lib/python3.7/ssl.py", line 98, in <module> import _ssl # if we can't import it, let the error propagate ImportError: dlopen(/Users/[username]/.pyenv/versions/3.7.0/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: /Users/[username]/.pyenv/versions/3.7.0/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so Reason: image not found

上記のような結果が出る場合、次のようにすれば解決するかと思います:

sh

1$ brew switch openssl 1.0.2s

参考

投稿2020/02/13 13:56

編集2020/05/18 03:00
glong35

総合スコア17

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

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

0

https://tsukada.sumito.jp/2019/01/14/pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl-module-in-python-is-not-available/

この記事を見るとadmin権限をつけて同じコマンドを打ったらエラーが出なかったそうです。sudoをつけて実行したら解決しませんか?

投稿2019/12/08 08:02

Yhaya

総合スコア439

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

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

yuda

2019/12/13 04:26

ご回答ありがとうございます。 sudo pip install requestsとしても変わらず下記のエラーが出てしまいます。。 The directory '/Users/user_name/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting requests Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/requests/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/requests/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/requests/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/requests/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/requests/ Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping Could not find a version that satisfies the requirement requests (from versions: ) No matching distribution found for requests python -m pip install --upgrade pip といったコマンドでも、sslエラーが出てしまいます。 証明書を作り、(https://pypi.org/simple/pip/)を信頼するようにそこに記述するべきなのでしょうか?もし、証明書を作る場合にはどのディレクトリに作れば良いのでしょうか? よろしくお願い致します。
yuda

2019/12/13 04:40

これは仮想環境外(macos上)でも出ています。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問