Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create poetry environment with python3.10 #5431

Closed
2 tasks done
ethanabrooks opened this issue Apr 8, 2022 · 8 comments
Closed
2 tasks done

Unable to create poetry environment with python3.10 #5431

ethanabrooks opened this issue Apr 8, 2022 · 8 comments
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@ethanabrooks
Copy link

ethanabrooks commented Apr 8, 2022

Issue

I am unable to create a poetry environment with python3.10.

> poetry shell
The currently activated Python version 3.8.10 is not supported by the project (^3.10).
Trying to find and use a compatible version.
Using python3.10 (3.10.4)
Creating virtualenv poetry-issue-wxXJaBmj-py3.10 in /home/ethanbro/.cache/pypoetry/virtualenvs
Virtual environment already activated: /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue-wxXJaBmj-py3.10
> which python
/usr/bin/python
> ls /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue-wxXJaBmj-py3.10
lib  local  pyvenv.cfg 

As you can see, there is no bin/ directory under /home/ethanbro/.cache/pypoetry/virtualenvs/poetry-issue-wxXJaBmj-py3.10.

If I change my pyproject.toml to python3.9 and then run poetry env use $(which python3.9), everything works fine (the virtualenv has a bin directory).

@ethanabrooks ethanabrooks added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 8, 2022
@expliyh
Copy link

expliyh commented Jun 8, 2022

I also had the same problem, I created a virtual environment using poetry env use python3.10 , but when I try poetry install , I was prompted The virtual environment found seems to be broken , also there is no bin/ in the venv directory. And poetry install the package to $HOME/.local/lib/python3.10/site-packages instead of the virtual environment directory.

我也遇到了相同的问题,我使用 poetry env use python3.10 创建了一个虚拟环境,但当我使用 poetry install 时,我被提示 The virtual environment found seems to be broken,在venv目录中同样没有 bin/。并且 poetry将软件包安装到了 $HOME/.local/lib/python3.10/site-packages 而不是虚拟环境目录。

My OS version is Ubuntu 22.04 lts

@christian-nils
Copy link

Same issue for me with the "The virtual environment found seems to be broken" message with poetry version 1.2.0b3.dev0 (installed from git@master) and with python 3.10. Works perfectly fine with python 3.9.

On Fedora 36.

@johnziebro
Copy link

johnziebro commented Jun 10, 2022

Same issue as above. I've completely uninstalled Poetry and reinstalled and done the same with Pyenv.
Gist: Pyproject.toml

Ubuntu 22.04
Pyenv 2.3.1 at /home/anon/.pyenv/bin/pyenv
Poetry 1.1.13 at /home/anon/.local/bin/poetry

Details:

Pyenv local python version:
cat .python-version

3.10.5

pyenv versions

system
* 3.10.5 (set by /media/anon/36782A484452D4B2/Projects/airtravel/.python-version)

poetry install

The currently activated Python version 3.10.4 is not supported by the project (^3.10.5).
Trying to find and use a compatible version.
Using python3 (3.10.5)
...

In fact python 3.10.5 is not used and 3.10.4 is:
cat .venv/pyvenv.cfg

home = /usr
implementation = CPython
version_info = 3.10.4.final.0
virtualenv = 20.14.1
include-system-site-packages = false
base-prefix = /usr
base-exec-prefix = /usr
base-executable = /usr/bin/python3.10

poetry shell
python

Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0] on linux

Manually setting the env python version fails also:
poetry env use 3.10.5

Creating virtualenv airtravel in /media/anon/36782A484452D4B2/Projects/airtravel/.venv
Using virtualenv: /media/anon/36782A484452D4B2/Projects/airtravel/.venv

poetry shell
python

Python 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0] on linux

poetry config --list

cache-dir = "/home/anon/.cache/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/anon/.cache/pypoetry/virtualenvs

@johnziebro
Copy link

johnziebro commented Jun 10, 2022

Issue 5190 appears to be a similar or duplicate issue and references a possible problem introduced in the new Poetry install script. Since I installed Poetry recently, this could indeed be true.

One the second attempt to fix this, I uninstalled both pyenv and poetry, installed pyenv first, then poetry, but still experienced the issue.

This may also be related to Issue 5077 which 5190 also references.

@johnziebro
Copy link

johnziebro commented Jun 10, 2022

Poetry Preview Release 1.2.0b1 addresses this issue:

Fixed an issue where the reported python version used for venv creation wasn't correct (#5086).

Steps to get a working environment:

  • Uninstalled Poetry
  • Installed the preview release 1.2.0b1:
    curl -sSL https://install.python-poetry.org | python3 - --preview
  • If using pyenv, and not creating your virtualenv prior to running poetry, you must change the
    poetry config to prefer-active-python
    :
    poetry config virtualenvs.prefer-active-python true

Now poetry will respect the pyenv activated python and workflow returns to normal:
poetry install
cat .venv/pyvenv.cfg # expecting python 3.10.5

home = /home/anon/.pyenv/versions/3.10.5
implementation = CPython
version_info = 3.10.5.final.0

See Docs: Managing environments for additional details.

@ethanabrooks
Copy link
Author

I tried uninstalling and reinstalling, but still encountering the same issue. I am not using pyenv, for the record.

@nirvana-msu
Copy link

The new prefer-active-python setting with a false default was such a gotcha for someone who's been relying on pyenv all along... It should be made a lot more prominent in the docs.

@randolf-scholz
Copy link

For me it worked again after purging poetry config files and reinstalling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

7 participants