pip.conf user = true conflicts with venv
See original GitHub issueEnvironment
- pip version: 20.2.3
- Python version: 3.8.5
- OS: Mint 20
Description
If pip.conf contains the user = true instruction then attempting to run pip in a venv results in:
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
I could find not command line option that is the oppposite of user (i.e. disables the pip.conf set user = true and so had to edit pip.conf in order to install packages into a venv with pip.
Expected behavior
I’d expect not to have to edit pip.conf. If pip is run from within a venv and is aware it’s in a venv how about silently ignoring the --user option? Or providing a command line option like --nouser to request it be ignored. That way Makefiles that implement venvs don’t bomb on a local dev system which by default has user = true (which after all is recommended … as we’re working desktop environments that have loads of Python code and fiddling with system libs is not recommended, we leave that to Ubuntu or our distro to do, and use user = true to do our Python dev work)
How to Reproduce
Add user = true to pip.conf (in ~/.config/pip/pip.conf on Ubuntu systems) and then create and activate a venv and try to install package with pip.
Output
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)

Top Related StackOverflow Question
This is not a supported end-user flag. Please don’t use this.
It shouldn’t (assuming a recent pip). If site-packages isn’t writeable, pip falls back to user site automatically. The recommendations you have seen are basically out of date and flawed, as you found out. (Never using sudo with pip is 100% correct advice, though 🙂) Unfortunately, it’s hard to get rid of out of date information on the internet 🙁