MacOS – Problem: How to clear all remnants of random.py, random.pyc, and random.pyo that isn’t part of Python’s standard library

command linemacospathpython

I wrote an import random code, and unfortunately saved it as the module's name I was trying to call. eg. random.py

I believe, but am not sure, that I created the random.py file twice and thus I deleted the random.pyc, twice, that popped up in the file holding all my python programs, after running import random in the terminal, twice.

If I didn't create the random.py twice, somehow another random.pyc (besides the first one) was in the file holding my programs and I deleted it.

All the people I asked told me to delete the .pyc, and any file with random, random.pyo as its name. I've checked all my user created files, and none of them fit the description.

One of them told me to find and clear the temporary cached version of the random.pyc and random.pyo.

My question is where on this MAC air Yosemite can I locate a temporary cached version, and how to safely clear it?

Best Answer

use mdfind to locate all the files with that name (you might need to grep -w for the string or use mdfind with a "kMDItemFSName == whatever.py" clause)

Once you know where you've sprayed those files, you could either edit it into the question or decide to do a clean install / migrate user data or remove all the python and then patch that together from a clean install on an external drive.

It's had to know what specific things you've done, but hopefully a few of the tools can narrow you down to some options.

If I were on deadline and just needed to know what version of python was running - I'd brew install python after setting up https://brew.sh

You'd then have three installations, but the one that runs from the shell is controllable with $PATH and you can be sure it's up to date with homebrew.