55

I use pipenv (version 2018.11.26) to manage dependencies in my project. Sometimes I want to add or update only one package and don't change versions of other packages. How can I achieve that? I've tried both

pipenv update --selective-upgrade requests

and

pipenv update --keep-outdated requests

but still versions of all the packages are updated during locking.

Pipfile & Pifile.lock: https://gist.github.com/jozo/d8351ed708e84c5ea0f69e82e585e5c6

jozo
  • 4,232
  • 1
  • 27
  • 29
  • 3
    I think `pipenv update --keep-outdated `will work for you [Issue GitHub](https://github.com/pypa/pipenv/issues/2665#issuecomment-426656712) – Maxime Apr 09 '19 at 12:20
  • 3
    No, it doesn't work @Maxime - everything is updated. – jozo Apr 10 '19 at 11:34
  • 3
    According to the discussion in this [Github Issue](https://github.com/pypa/pipenv/issues/966) this isn't possible for now. – Jakub Kukul Jul 18 '19 at 16:41

2 Answers2

51

Running pipenv install/uninstall/update with --keep-outdated will prevent pipenv from updating unrelated locked packages. (It's odd that this is not the default befavior).

If you don't want some packages to ever be updated automatically, you should pin those in your Pipfile, e.g:

[packages]
django = "==2.2"
djangorestframework = "==3.9.2"
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
  • 29
    `--keep-outdated` doesn't give me an error but it's still updating everything in the pipfile, for me. – Ren May 21 '19 at 17:01
  • 1
    @Yokhen: Please provide a minimal, reproducible example (perhaps, in a different question). At the time of writing `--keep-outdated` worked as intended for me. – Eugene Yarmash May 21 '19 at 21:02
  • 13
    @EugeneYarmash `keep-outdated` does not work for specific package as reported in this [issue](https://github.com/pypa/pipenv/issues/2665#issuecomment-426656712). It seems there is no solution at this time. – David Dahan Jul 29 '19 at 10:26
  • For me, `pipenv unistall --keep-outdated foobar` removed `foobar` from `Pipfile` but not from `Pipfile.lock` – Flimm Dec 13 '21 at 08:39
  • How do I update the pinned packages via pipenv ? – Waqar Ali Dec 23 '21 at 09:47
  • @WaqarAli Update the version of the package in `Pipfile` and run `pipenv update `. – Eugene Yarmash Feb 21 '22 at 10:59
  • For me it worked with --ignore-pipfile : pipenv install --ignore-pipfile --keep-outdated – Ankush Jul 20 '22 at 05:12
1

I am using pipenv version 2023.3.20 and according to the documentation it seems the upgrade command does it.

For example, to downgrade flake8 to <6 in the dev packages, I ran pipenv upgrade --dev "flake8<6", and it only affected flake8 in the Pipfile.lock, pinning to version 5.0.4.

Fabio Ramalho
  • 161
  • 1
  • 9
  • I guess if `install` is already taken, `upgrade` makes sense? I would've chosen `add` instead ¯\_(ツ)_/¯ – Android May 23 '23 at 22:04
  • Well, on my comment I just mentioned a way to address the particular problem. I haven't used `pipenv` that much, but so far and used already tools like `Poetry`, I found some commands behaviour a bit confusing to be honest. – Fabio Ramalho May 30 '23 at 09:25