Help us understand the problem. What is going on with this article?

pipenv で "No versions found" というエラーが出た場合の対処法

事象:pipenv を使ったパッケージのインストール時のエラー

pipenv を使って以下のようにインストールを試みたところ

pipenv install <package name>

以下のように怒られてしまった。

[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches request
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches request
No versions found
Was https://pypi.org/simple reachable?

原因

pipenv が使う pip の SSL 認証がうまく行っていないのが原因らしい。
普通に pip install をしていたときも

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)

などと怒られていたので、暫定対処として

pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host <package name>

としてお茶を濁していたが、pipenv では上記のオプションを付けることができない模様

対処法

pipの設定ファイルであるpip.confに必要な設定をすることで解決できる。
Mac の場合

mkdir ~/.pip
vim ~/.pip/pip.conf

として

pip.conf
[global]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org

を作ってあげれば良い。
それ以外の環境の場合、参考にした https://qiita.com/agajo/items/73d6f14855da703972e0 を見ると良い。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした