4

After installing some Python Modules via homebrew, homebrew told me to run the following code. I don't need those modules anymore and want to cleanup everything. Can i remove (should i?) remove this entry? And how i remove it?

Python modules have been installed and Homebrew's site-packages is not in your Python sys.path, so you will not be able to import the modules this formula installed. If you plan to develop with these modules, please run:

mkdir -p /Users/rain/.local/lib/python2.7/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/USERNAME/.local/lib/python2.7/site-packages/homebrew.pth

Mac OsX 10.10.2

Golian
  • 43
  • 1
  • 5
  • pth files are read when the `site` module is loaded on python init, and so the above script would cause that directory to be put into your local homebrew python. You can remove it, since you're removing the python. For more about how sys.path works, see this answer http://stackoverflow.com/a/38403654/850326 – djhaskin987 Jul 15 '16 at 20:21

1 Answers1

3

You can safely delete /Users/USERNAME/.local/lib/python2.7/site-packages/homebrew.pth if you aren't using any Homebrew-installed python modules.

.pth files are a way of adding paths to sys.path. Lines in a .pth file which are paths are added to sys.path; lines in a .pth file starting with import are executed.

The line starting with import in the homebrew.pth file makes the site-packages directory under the Homebrew prefix a special site-packages directory, which both adds it to sys.path and ensures that any .pth files that it contains are read and processed.

Tim Smith
  • 6,127
  • 1
  • 26
  • 32