Pip Permissions


In my first post I ran into some permisions issues related to Python and Pip.

Confession Time - Pip Permissions

When my original Mac was new, I tried to install something early on with pip - and I took some shortcuts. One in particular, I suspect, will haunt me until I nuke-and-pave my Mac… overuse of sudo to get around install issues.

I’m not the first to take the easy way out and knew using sudo with pip is a security risk. Despite that I let myself follow some well intentioned installation advice from a project long since forgotten instead of using virtualenv or some alternative.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
> python --version
Python 2.7.10
> pip install Pygments
Collecting Pygments
Downloading Pygments-2.2.0-py2.py3-none-any.whl (841kB)
100% |████████████████████████████████| 849kB 1.8MB/s
Installing collected packages: Pygments
Exception:
...
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pygments’

Taking the “easy” way out with the following command instead of setting up my virtual environments like I should…

1
> sudo chown -R $USER /Library/Python/2.7/site-packages/

Installing Pygments again…

1
2
> pip install Pygments
Successfully installed Pygments-2.2.0

Update: Hugo v0.28+ Uses Chroma

According to Hugo’s Syntax Highlighting page, Hugo have moved to Chroma instead of Pygments for default syntax highlighting for speed purposes. I found this out when some of the formatting on my code blocks didn’t look right after I upgraded.

I will need to come back through and decide if I’m going to fully move over to Chroma - since I’m still early it’s probably the right move so that I’m not fighting against the default.

Update: I did end up making the update to Chroma.

Update: I did finally switch to venv (Python 3) and virtualenv (Python 2) as specified in Creating Virtual Environments.