poetry icon indicating copy to clipboard operation
poetry copied to clipboard

`poetry env use` fails with "The specified Python version (3.7) is not supported by the project (^3.7)"

Open oliver-charlesworth opened this issue 6 years ago • 2 comments

  • [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: OSX 10.15.1

  • Poetry version: 1.0.0

  • Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/oliver-charlesworth/3724472ec1d981eecc46d006d374d0bd

Issue

With a new Poetry project with python = "^3.7" in the pyproject.toml, I get the following:

> poetry env use 3.7 -vvv

[NoCompatiblePythonVersionFound]
The specified Python version (3.7) is not supported by the project (^3.7).
Please choose a compatible version or loosen the python constraint specified in the pyproject.toml file.

Traceback (most recent call last):
  File "/Users/oliver/.poetry/lib/poetry/_vendor/py2.7/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/oliver/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/oliver/.poetry/lib/poetry/_vendor/py2.7/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/oliver/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/oliver/.poetry/lib/poetry/console/commands/env/use.py", line 23, in handle
    env = manager.activate(self.argument('python'), self._io)
  File "/Users/oliver/.poetry/lib/poetry/utils/env.py", line 225, in activate
    self.create_venv(io, executable=python, force=create)
  File "/Users/oliver/.poetry/lib/poetry/utils/env.py", line 520, in create_venv
    self._poetry.package.python_versions, python_minor

Poetry is installed as recommended, thus runs under Python2.7. I have a python3.7 executable on the path:

> python3.7 --version
Python 3.7.5

The bug appears to be here: https://github.com/python-poetry/poetry/blob/fbcea50d2003e85bcaac9916d2c60e7b08926150/poetry/utils/env.py#L494-L509

python_patch is not overwritten in the executable case, so the check further down is effectively run against Poetry's Python version.

oliver-charlesworth avatar Dec 31 '19 11:12 oliver-charlesworth

Just realised this duplicates #1808, which is already fixed on master, so closing.

oliver-charlesworth avatar Dec 31 '19 12:12 oliver-charlesworth

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Mar 03 '24 08:03 github-actions[bot]