windowspowershellpython-poetrymicrosoft-store

Unrecognized command after poetry's installation on Windows 11


I never had troubles with the official installation of Poetry on Ubuntu systems. Now I'm trying to install it on Windows 11 in which there is Python 3.10. I've used the Power Shell commando as explaned here:

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -

After that I've checked poetry:

poetry --version
  • poetry --version
  • + CategoryInfo          : ObjectNotFound: (poetry:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    

On JetBrains' site there is a guide to install poetry and I've used the command below at the end of installation:

$Env:Path += ";C:\Users\massi\AppData\Roaming\Python\Scripts"; setx PATH "$Env:Path"

But nothing is changed. Any suggestions?


Solution

  • Given your post-installation attempt to both update the in-process Path environment variable as well as its persistent definition, via setx.exe, the implication is that the poetry.exe executable is not located in C:\Users\massi\AppData\Roaming\Python\Scripts, despite what the installation instructions state, which is indeed the case:

    # Discover the true location of poetry.exe, via $env:LOCALAPPDATA
    $actualDir = 
      (
        Get-ChildItem $env:LOCALAPPDATA -Recurse -Filter poetry.exe -ErrorAction Ignore
      ).FullName[-1] | Split-Path
    
    # Add it to the in-process copy of the Path environment variable
    $env:Path += ";$actualDir"
    
    # This should now succeed.
    poetry --version
    

    As for persistently updating the Path environment variable: