Yearly Archives: 2020

4 posts

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

Reverting a bad commit and removing it completely from Github

Let’s say you accidentally commit and push a file full of passwords (like a .env file) that you don’t want other people to want and now it is part of your public project on Github? How do you get rid of that? Fear not, follow these two commands and you’ll be back to before you took that ill-fated action.

Before beginning, make sure that you backup any files and changes you’d like to preserve elsewhere as your work in the repository will be wiped back to where you were at your previous commit.

git reset –hard HEAD^
git push origin +master –force

(Note that here I used “master” as that was the branch I was working on, you’ll want to change “master” to whatever your branch name is and use that in the command)

Useful links: https://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github

readlink: command not found

I’ve been working on a bunch of projects that involve Python and a decent amount of commands written and issued in terminal. At one point, I was trying to boot up a local server for a web app I was running and kept running into the error “readlink: command not found”. After a ton of searching and attempting to understand what was going on, I was able to find a solution that solved my problem and allowed me to get back on track.

The core of this issue is changes made to your .bash_profile that renders it unreadable or unparseable so you need to jolt it out of that state to allow it to function normally again.

The answer here on Stackoverflow ultimately led to me solving my problem.

It is happens when you just copy the line (below) into the .bash_profile without removing the quotes (‘xxxx’)
export PATH=’/usr/local/bin:$PATH’

To resolve, just run in console:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

Then, edit again the file removing the quotes:
vim ~/.bash_profile

The terminal commands that I ran locally ended up looking like this

Nicholass-MacBook-Pro:post-covid-19 nicholaspezarro$ export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
Nicholass-MacBook-Pro:post-covid-19 nicholaspezarro$ source ~/.bash_profile

Hopefully this helps you out if you’re having this issue!

Creating a .slate file for Slate (Mac Window Management): Resolve “Could not load ~/.slate or ~/.slate.js”

A while back I was looking for a solution to restore my window setup when I went between being at my desk and bringing my laptop to meetings. I settled on Slate which is a great, lightweight solution to save your window positions and quickly restore them exactly as they were. Unfortunately, it can be a bit tricky at times to setup as you need to create a .slate file in your Home directory which is not something you can easily in Finder or even with a text editor like Sublime.

If you don’t have your file set up you’ll keep getting this error:


The dreaded “Could not load ~/.slate or ~/.slate.js”

Thankfully, it is very simple to resolve using Terminal. Just follow these steps.

Open Terminal and type (or paste in) the following commands:
cd $HOME
touch .slate
open -a textedit .slate

At this point, you’ll see a textEdit window pop up with .slate as the title. Save that file and you’re set!

Now, when you save your window positions in Slate (Take Snapshot) they’ll be stored for your next session and you can easily restore them (Activate Snapshot)

Big thank you to harzivi for their helpful suggestion on Github!