From Docker :
Use a non-root user (namely circleci) by default. Many applications refuse to run as run (e.g. chrome) or their behavior differs when run as root (e.g. tar file ownership behavior)
That’s fine, but when you try to install anything using pip, you get Permission Denied: /usr/local/lib/python3.6/site-packages
The workarounds that work are:
- using sudo pip install (not recommended by pip team)
- sudo chowning or chmoding the directory first
- use
pip install --user
– note that default$PATH
does not include~/.local/bin
, so any binaries installed by pip likepy.test
will fail unless you changePATH
before using those commands - use a venv – same caveats apply as you must
source activate
your venv before any pip-installed commands
Recommend at least documenting this for anyone switching from docker’s base python
to your circleci/python
images.