Daily Archives: May 23, 2020

1 post

Fix broken pipenv in a virtual environment (could not find a version that matches X)

I’d messed up my pipenv previously by trying to get it to install a module that just wasn’t working out for me. In using pipenv install -skip-lock I’d inadvertently put my pipenv in a state where it was constantly stuck in a loop where it was trying to install “blocks” through pipenv which just wasn’t possible.

This is what my error log looked like in terminal:

[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 blocks
No versions found
Was https://pypi.org/simple reachable?

To fix the problem, I ended up deleting my pipfile and running the same install command again. It installed the package I was trying to get (elasticsearch) and updated Pipfile.lock with the new project requirements.

Note: Your pipfile will look something like this in your project folder.

My terminal output after deleting the pipfile in my virtual environment:

(venv) Nicholass-MacBook-Pro:microblog nicholaspezarro$ pipenv install elasticsearch
Creating a Pipfile for this project…
Installing elasticsearch…
Adding elasticsearch to Pipfile’s [packages]…
✔ Installation Succeeded
Pipfile.lock (0b8641) out of date, updating to (9d3b63)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (0b8641)!
Installing dependencies from Pipfile.lock (0b8641)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:00