Marmstrong
Marmstrong

Reputation: 1786

Poetry can't find Python 2.7 via Pyenv

With Poetry version: 1.1.13 I get the following error when trying to use Python 2.7.18 via Pyenv...

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

This occurs when 2.7.18 is set up locally (pyenv local 2.7.18) and globally (pyenv global 2.7.18). Running python within the directory in question launches the terminal...

Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

But when I install Python 3.9.6 and set it as the local Python version, Poetry works perfectly correctly!

Has anyone seen this before? Am I missing something?

Upvotes: 2

Views: 688

Answers (1)

Marmstrong
Marmstrong

Reputation: 1786

%USERPROFILE%.poetry\bin\poetry.bat was calling Python3 which can't find Python2 installs. When installing Poetry get-poetry.py is called. The _which_python method (line 666) determines if the call in poetry.bat is Python3 or Python by which version of Python it finds during the install.

If you have already installed Poetry simply modify the poetry.bat file to be python. For future installations with Pyenv ensure that a 2.7 Python version is set as global.

Upvotes: 1

Related Questions