Poetry: Poetry Command Not Found on zsh

Created on 18 Oct 2018  Â·  21Comments  Â·  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name:
  • 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.

Most helpful comment

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.

All 21 comments

If you do:

echo $PATH

What does it give you?

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

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?

Its weird.

I don't have a ~/.zprofile at all.

I do have a ~/.profile and that does have the line export PATH="$HOME/.poetry/bin:$PATH"

Is it oh-my-zsh doing something?

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.

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? 

Yes it does.

I had the same issue, my system does not have a .profile and zsh does not create a .zprofile by default.
Poetry installed in my .bash_profile. Consider adding export PATH="$HOME/.poetry/bin:$PATH" to .zshrc if no .zprofile exists.

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.

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.

Yes, same issue here.

Can also confirm that this does not automatically happen. As a user, I would have expected the PATH to have been updated upon installation.

Same here, I just installed it using the cURL, and in my system I only have the .zshrc, which was not updated with the export PATH="$HOME/.poetry/bin:$PATH"

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

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.

Same issue. No .zprofile is created. Also, .poetry folder is not created. I have Windows 10 with WSL2. Running which poetry points to my Windows poetry install and trying poetry install gives error /usr/bin/env: ‘python\r’: No such file or directory. Something is up...

Running pip install poetry at first yields

Defaulting to user installation because normal site-packages is not writeable
Collecting poetry
  Using cached poetry-1.0.10-py2.py3-none-any.whl (224 kB)

then packages install. Is the user install pointing to the Windows user folder rather than the WSL distro user folder?

Even trying pip install --user poetry does not solve the problem. Only manually creating ~/.zprofile and executing export PATH="$HOME/.poetry/bin:$PATH" fixes problem.

@sdispater and @abn do we know why this is still happening?

I should have clarified on my comment above that I am also on WSL, although I was on WSL1 at time i encountered the bug

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thmo picture thmo  Â·  3Comments

jbarlow83 picture jbarlow83  Â·  3Comments

Euphorbium picture Euphorbium  Â·  3Comments

ambv picture ambv  Â·  3Comments

ulope picture ulope  Â·  3Comments