6

How to I upgrade to the latest version?

Specification:

  • Windows 10,
  • Visual Studio Code,
  • Ubuntu Bash.

Current Version:

me@PF2DCSXD:/mnt/c/Users/user/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ python3 --version
Python 3.8.10

Attempt to update | poetry self update:

me@PF2DCSXD:/mnt/c/Users/user/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ poetry self update

  RuntimeError

  Poetry was not installed with the recommended installer. Cannot update automatically.

  at ~/.local/lib/python3.8/site-packages/poetry/console/commands/self/update.py:389 in _check_recommended_installation
      385│         current = Path(__file__)
      386│         try:
      387│             current.relative_to(self.home)
      388│         except ValueError:
    → 389│             raise RuntimeError(
      390│                 "Poetry was not installed with the recommended installer. "
      391│                 "Cannot update automatically."
      392│             )
      393│

Please let me know if there is anything else I can add to post.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
StressedBoi69420
  • 1,376
  • 1
  • 12
  • 40

3 Answers3

9

The error message suggests you've probably installed poetry with pip, which does not support automatic poetry updates. You should uninstall the poetry version currently installed, and reinstall it using the recommended method, which uses a custom installation script.

On osx/linux, you'll just have to run curl -sSL https://install.python-poetry.org | python3 - to download and run this installation script.

Seon
  • 3,332
  • 8
  • 27
0

As per the accepted answer, it's quite likely that you've installed poetry with pip. But it you find pip uninstall poetry returns a warning saying that poetry is not installed, another possibility is that you've installed it with pipx.

Running pipx list will show you whether this is the case. You could then run pipx upgrade poetry, or you may want to uninstall it and just rely on poetry to manage its own installation/upgrade, as this seems to be fairly robust now.

(I add this on the off chance that someone else, like me, had installed pipx for the specific purpose of managing their poetry installation and then completely forgotten about it, and finds their way to this question...! )

Tim
  • 1,839
  • 10
  • 18
0

This error still occurs after installing Poetry with the recommended method:

curl -sSL https://install.python-poetry.org | python3 -

...and then attempting to update Poetry with:

poetry self update
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/34790032) – Andrew Louw Aug 07 '23 at 16:18