Pip install develop mode PEP517

PEP517 / PEP518 introduced pyproject.toml as a supplement and even replacement for setup.py. Pyproject.toml has been adopted by major Python projects including PyTest. Some computers, especially those using system Python may be configured without a user site-packages directory. When pyproject.toml is present, systems without a Python user site-packages directory may fail on pip install -e . with errors including:

running develop WARNING: The user site-packages directory is disabled. error: can’t create or remove files in install directory

The fix below will work with or without pyproject.toml, installing just like usual:

  • pip install . → under user site-packages, a static copy of the package (any package code changes require package reinstall)
  • pip install -e . → Python-style link in user site-packages to this code directory (live development code)

Note: some systems require python3 -m pip instead of plain pip.

Fix

A general fix is to make setup.py contain site.ENABLE_USER_SITE = True. If the computer admin has locked down the user directory (very rare) this may still not work.

This installs this package, as well as any prerequisites specified and not already installed under the Python user directory site.USER_SITE.

#!/usr/bin/env python3
import site
import setuptools

# PEP517 workaround
site.ENABLE_USER_SITE = True

setuptools.setup()

Notes

  • Pip issue discussing this matter