Poetry installed but `poetry: command not found`

Viewed 25188

I've had a million and one issues with Poetry recently.

I got it fully installed and working yesterday, but after a restart of my machine I'm back to having issues with it ;(

Is there anyway to have Poetry consistently recognised in my Terminal, even after reboot?


System Specs:

  • Windows 10,
  • Visual Studio Code,
  • Bash - WSL Ubuntu CLI,
  • Python 3.8.

Terminal:

me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ poetry run python3 cli.py
poetry: command not found
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
Retrieving Poetry metadata

This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.
Latest version already installed.
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ poetry run python3 cli.py
poetry: command not found
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ 

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

4 Answers

When I run this, after shutdown of bash Terminal:

export PATH="$HOME/.poetry/bin:$PATH"

poetry command is then recognised.

However, this isn't enough alone; as every time I shutdown the terminal I need to run the export.

Possibly needs to be saved in a file.

To follow-up on @StressedBoi69420's answer, could you add the line he suggested, i.e. export PATH="$HOME/.poetry/bin:$PATH" to your .bashrc?

As per this other Stack Overflow post What is the default install path for poetry and @arshbot's answer, I have added the line export PATH=$PATH:$HOME/.poetry/bin to my .zshrc and it seems to be working.

Since this is the top StackOverflow result for "poetry command not found"...

For Mac users, create a .zshrc file in your home folder with the following:

export PATH="$HOME/.local/bin:$PATH"

Just to add some beginner level context around Julien's excellent answer, to find and edit your .zshrc file, you need to use your default editor (in this case i am using VSCode) and run:

>> code ~/.zshrc

...and, crucially, restart the terminal.

More details and the source of this info here: https://superuser.com/questions/886132/where-is-the-zshrc-file-on-mac

Related