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.

Disable upgrades to existing python modules which were not installed via pip

See original GitHub issue

What’s the problem this feature will solve?

pip lets me upgrade python modules installed by the system package manager

Describe the solution you’d like

pip should not touch packages not installed by it 😉

$ rpm -qf /usr/lib64/python2.7/site-packages/nacl
python2-pynacl-1.2.0-2.fc28.x86_64

$ pip freeze
cffi==1.11.5
ply==3.9
pycparser==2.14
PyNaCl==1.2.0
six==1.11.0

$ sudo pip install --upgrade pynacl
...
Successfully installed pycparser-2.18 pynacl-1.2.1

Alternative Solutions

🤔

Additional context

I initially posted it here. For starters, I have opened a PR to make pip_installed_by_pip() function more generic so that it can be used by whoever implements this feature.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:18 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
ncoghlancommented, Jul 20, 2018

I agree with @dstufft that only touching files installed specifically by pip by default would be problematic, since it inhibits migrating to pip from other non-system installers.

What I do like though is the notion of being able to configure pip to be more opinionated about what it’s willing to touch, and provide a reasonably helpful error message when refusing to modify things. That way a distro-provided pip can ship with that configuration set, and python3 -m pip --upgrade pip will fail with guidance on what the user should do instead.

I’m thinking along the lines of a python-installers.toml file that can appear alongside any pip.conf with entries like:

[installer.dnf]
modify = false
message = "This is a system managed package, use `dnf` to update it."

(Tangentially related: https://github.com/pypa/pip/pull/5424 is a proposal to provide a way to add an extra “wrapper” identifier to the User Agent info that pip sends to PyPI. If that ends up being pursued, then it may make sense to structure it so that the wrapper info also ends up in the INSTALLER file)

1reaction
pradyunsgcommented, Dec 11, 2022

This is now covered by https://peps.python.org/pep-0668/.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade package without upgrading dependencies using pip?
Upgrade package and all dependencies to latest version: pip install --upgrade --upgrade-strategy eager (default in old versions)
Read more >
Installing, uninstalling, or upgrading Python modules using ...
Open a terminal window. To uninstall, or remove, a package use the command '$PIP uninstall <package-name>'. This example will remove the flask ...
Read more >
preventing pip from removing system packages during upgrade
One way to fix this problem is to get pip to upgrade my local packages and ignore the system-installed ones (if possible). Can...
Read more >
How to use pip (Install, update, uninstall packages) - nkmk note
Install pip · pip and pip2, pip3 · Details of installed package: pip show · List of installed packages: pip list , pip...
Read more >
Using Python's pip to Manage Your Projects' Dependencies
Note: On some Linux (Unix) systems like Ubuntu, pip comes in a separate package called python3-pip , which you need to install with...
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