poetry: Poetry Command Not Found on zsh

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: <macOS 10.14 Mojave>
  • Poetry version: <0.12.2>

Issue

I am a noob to poetry, and just installed poetry using the curl command.

I got the following:

Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

$HOME/.poetry/bin

This path will then be added to your `PATH` environment variable by
modifying the profile files located at:

$HOME/.profile
$HOME/.zprofile

You can uninstall at any time with `poetry self:uninstall`,
or by executing this script with the --uninstall option,
and these changes will be reverted.

Installing version: 0.12.2
  - Downloading poetry-0.12.2-darwin.tar.gz (7.00MB)

Poetry (0.12.2) is installed now. Great!

To get started you need Poetry's bin directory ($HOME/.poetry/bin) in your `PATH`
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run `source $HOME/.poetry/env`

But when I start a new shell, and run poetry --version, I get: zsh: command not found: poetry

Works fine if I do source $HOME/.poetry/env. But doesn’t retain for a new shell. I have to do this every time I open a new shell.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 27 (5 by maintainers)

Most upvoted comments

I have added export PATH="$HOME/.poetry/bin:$PATH" to the my .zshrc, and things work.

I notice that Google Cloud SDK automatically appended its path and path completions to my .zshrc. Maybe thats something poetry could also do?

Closing this issue.

So your shell does not source neither the .zprofile file nor the .profile file. That’s weird since ~/.zprofile should always be sourced by zsh.

If it’s not you might want to do it yourself in your .zshrc file.

Just to be sure: has export PATH="$HOME/.poetry/bin:$PATH" been added to ~/.zprofile?

I’d like to mention users are still running into this issue and it would be nice if it was reopened and addressed, either during installation or in the docs.

zsh mainly uses .zshrc, it would definitely be a good idea to check for .zshrc if no .zprofile exists. Just ran into the same issue.

Issue still exists, and should be reopened.

zsh is the default shell for new installations of macOS for the last several major OS releases. Therefore having this issue not fixed means that Poetry will not be usable after installation by default on new macOS machines & VMs.

In a newly opened shell:

/usr/local/opt/node@8/bin:/Users/swarnavallabhaneni/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

And after sourcing via source $HOME/.poetry/env

/Users/swarnavallabhaneni/.poetry/bin:/usr/local/opt/node@8/bin:/Users/swarnavallabhaneni/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Just to check: if you create a ~/.zprofile and add export PATH="$HOME/.poetry/bin:$PATH" to it and then restart your shell, does it work?

This issue might need to be reopened as it’s still an issue, and just means the install flow isn’t as smooth. I had the same issue as I didn’t have a .zprofile or a .profile so just had to add the path myself in the .zshrc file.

i’m on linux and also ran into this issue… similarly to those above the workaround of adding export PATH="$HOME/.poetry/bin:$PATH" to my ~/.bashrc file worked

Yes, same issue here.

Still running into the same issue.

So your shell does not source neither the .zprofile file nor the .profile file. That’s weird since ~/.zprofile should always be sourced by zsh.

If it’s not you might want to do it yourself in your .zshrc file.

Just to be sure: has export PATH="$HOME/.poetry/bin:$PATH" been added to ~/.zprofile?

If the PATH for poetry is there in .profile then you have to just logout from the current session and log in again. The changes in .profile will be reflected.

Had the same problem today, was left scratching my head. Noticed it worked on bash. On a default installation of oh-my-zsh, the PATH variables won’t have $HOME/.local/bin added to it. I didn’t notice this when changing my system shell because Rust Cargo which also has a binary there modifies the environment and sources a binary located elsewhere too. However, instead of using the export PATH provided by Poetry, I copied mine from my .bashrc, which was as follows:

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

Yes it does.