Circleci/python Docker images disallow pip install due to directory ownership

docker
python

#1

From https://hub.docker.com/r/circleci/python/ :

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:

  1. using sudo pip install (not recommended by pip team)
  2. sudo chowning or chmoding the directory first
  3. use pip install --user – note that default $PATH does not include ~/.local/bin, so any binaries installed by pip like py.test will fail unless you change PATH before using those commands
  4. 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.


#2