question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`poetry env` doesn't work on Windows after install-poetry.py

See original GitHub issue
  • 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: Windows 10

  • Poetry version: 1.1.11

  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

After installing poetry, creating a fresh project and running poetry env list the following error occurs:

EnvCommandError

Command python -W ignore - errored with the following return code 1, and output:
'python' is not recognized as an internal or external command,
operable program or batch file.
input was : import sys

if hasattr(sys, "real_prefix"):
    print(sys.real_prefix)
elif hasattr(sys, "base_prefix"):
    print(sys.base_prefix)
else:
    print(sys.prefix)


at c:\...\poetry\venv\lib\site-packages\poetry\utils\env.py:1183 in _run
    1179│                 output = subprocess.check_output(
    1180│                     cmd, stderr=subprocess.STDOUT, **kwargs
    1181│                 )
    1182│         except CalledProcessError as e:
  → 1183│             raise EnvCommandError(e, input=input_)
    1184│
    1185│         return decode(output)
    1186│
    1187│     def execute(self, bin, *args, **kwargs):

This appears to be due to the following at lines 1233-1236 in https://github.com/python-poetry/poetry/blob/1.1/poetry/utils/env.py:

            if not bin.endswith(".exe"):
                bin_path = self._bin_dir / (bin + ".exe")
            else:
                bin_path = self._path / bin

I believe in the first case self._path should be used instead of self._bin_dir.

This problem doesn’t appear to happen (the function is never called) when poetry is installed with get-poetry.py instead of install-poetry.py. I don’t know why that is, but it’s a good workaround. I think the above code is wrong nonetheless.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tom-bowlescommented, Oct 27, 2021

With apologies, I’m pinging the 4 members of the python-poetry project since the “@python-poetry/triage” as mentioned in the docs doesn’t work: @sdispater @abn @finswimmer @stephsamson

This issue has been present since 1.1.9 and renders poetry unusable on Windows. It’s a simple typo with a one-line fix.

1reaction
zndr27commented, Dec 18, 2021

Any timeline on when this will be resolved?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry installation in Windows doesn't work - Stack Overflow
I am using Windows 10 and Python 3.10.0, when I try on Linux it runs normaly. Creating virtualenv manim-tx2tvM36-py3.10 in C:\Users ...
Read more >
Configure a Poetry environment | DataSpell Documentation
Install Poetry . Open Terminal (on macOS and Linux) or PowerShell (on Windows) and execute the following command: macOS. Windows.
Read more >
Managing environments | Documentation - Poetry
Poetry makes project environment isolation one of its core features. What this means is that it will always work isolated from your global...
Read more >
How To Install Poetry to Manage Python Dependencies on ...
In this tutorial you will install Poetry using the official installation script, set up a Poetry project with a virtual environment, ...
Read more >
Python Virtual Environments tutorial using Virtualenv and Poetry
This blog post is mostly aimed at people who didn't work with it. ... For Windows: $ py -3.6 -m pip install poetry...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found