question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip.conf user = true conflicts with venv

See original GitHub issue

Environment

  • 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:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
pradyunsgcommented, Oct 10, 2020

FYI there’s a --no-user flag.

This is not a supported end-user flag. Please don’t use this.

1reaction
pfmoorecommented, Oct 10, 2020

Without sudo pip fails unless you specify --user

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 🙁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip default behavior conflicts with virtualenv? - Stack Overflow
in my case a manjaro update added a pip.conf file in /etc/pip.conf forcing user=true . Changed to false and the normal behaviour returned....
Read more >
The one pip config you need to have - Waylon Walker
Pip is the pacakage tool for python. It installs third-party packages and is configurable. One of the configuration settings that I highly ...
Read more >
Further Configuration of pip and Virtualenv
export PIP_REQUIRE_VIRTUALENV=true ... If you try to use pip install outside of a virtual environment pip will gently ... [global] require-virtualenv = true....
Read more >
User Guide - pip documentation v22.3.1
pip install --user follows four rules: When globally installed packages are on the python path, and they conflict with the installation requirements, they...
Read more >
User Guide - pip documentation v21.1.dev0
There is also a legacy per-user configuration file which is also respected. ... a package that conflicts with a package in the virtualenv...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found