-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Poetry does not use active pyenv when creating virtual environment #651
Comments
Turns out that explicitly activating the correct Python version (e.g. by running |
|
I'm not sure where. When I run
I'll do some debugging - I'm having trouble locating the code where poetry detects the Python version, once I find where that is I'll know more. |
How did you install Poetry? |
I've used the installer from the website - I've recently updated from 0.11.5 to 0.12.8, maybe some leftovers from the old installation? Poetry is installed into another Python version managed by |
Possibly. Try |
Hm, though I had done that, but it was still there. However, removing it didn't change anything (and |
What is the output of |
$ poetry debug:info
Poetry
======
* Version: 0.12.8
* Python: 3.6.5
Virtualenv
==========
* Python: 3.6.5
* Implementation: CPython
* Path: NA
System
======
* Platform: darwin
* OS: posix
* Python: /Users/bjoernpollex/.pyenv/versions/3.6.5 |
I don't know what to say. Poetry sees Python 3.6.5 from pyenv not 3.7.1. What is the output of |
$ pyenv which python
/Users/bjoernpollex/.pyenv/versions/3.7.1/bin/python |
That's so weird. And just to be sure: can you execute |
$ which poetry
/Users/bjoernpollex/.poetry/bin/poetry |
Ok, I found out that if I remove the |
Guys, also see #655 -- the current behavious is a regression, version 0.12.4 worked correctly for me. |
I confirm this bug with poetry 0.12.10: $ poetry debug:info
Poetry
======
* Version: 0.12.10
* Python: 3.6.7
Virtualenv
==========
* Python: 3.6.7
* Implementation: CPython
* Path: NA
System
======
* Platform: linux
* OS: posix
* Python: /home/bersace/.local/venvs/poetry
$ pyenv which python
/home/bersace/.cache/pyenv/versions/3.7.1/bin/python
$ python --version
Python 3.7.1
$ poetry install
[RuntimeError]
The current Python version (3.6.7) is not supported by the project (^3.7)
Please activate a compatible Python version.
install [--no-dev] [--dry-run] [-E|--extras EXTRAS] [--develop DEVELOP]
|
@bersace As you can see the Python used is If you do not use the recommended installer Poetry is linked to the Python version it has been installed for. In this case I suspect you used So, this is not a bug in Poetry but a limitation of the entrypoints functionality of the Python ecosystem. I'd suggest reinstalling Poetry with the recommended installer. |
@sdispater Yes, i installed poetry using pipsi as documented here : https://github.com/sdispater/poetry/blob/master/docs/docs/index.md#installing-with-pipsi |
@sdispater using get-poetry.py works fine ! Thank you ! |
I would love to see poetry work when installed with Also, I juste tried the recommended installation method ( $ poetry install
[RuntimeError]
The current Python version (2.7.13) is not supported by the project (~3.6)
Please activate a compatible Python version.
install [--no-dev] [--dry-run] [-E|--extras EXTRAS] [--develop DEVELOP] I uninstalled poetry, re-installed it using I was able to fix this by first running Can't |
@pawamoy Poetry is intentionally not managing python versions for you, as that would unnecessarily bloat the scope of the tool. Using |
To circle back to the original issue, I've found a fix (as described above), but had no luck in figuring out what the root cause was. I do have the feeling that it's a |
I second this. That would be nice if get-poetry installs poetry in e.g. ~/.local/lib/pypoetry and added a link in ~/.local/bin. That's more a matter of taste. |
The systemd file hierarchy spec (https://www.freedesktop.org/software/systemd/man/file-hierarchy.html) recommends |
I was having similar issues turns out it was an issue with
|
@jeannei That solution does seem to work. Thanks! |
I was having the same issue. Im using pyenv to manage python versions. I was changing my python version using |
Had the same issue; removing .python-version from my home directory solved it |
Maybe worth to add it here: sometimes my system Python is upgraded through system-updates, and it usually breaks my Python setup. When Poetry can't find the right Python versions anymore, and everything else failed what I do is:
Then I can reinstall everything:
A bit brutal, but it also allows to clean up a bit 😄 |
Added info: pipenv using a ported Pipfile from the pyproject.toml did used python3.9.2 |
Found the problem, the virtualenv had been created originally with the system python:
Some hints on #926 are misleading but I managed to fix this one. |
@bjoernpollex I'm still running into this issue with a
|
the same issue here. |
At the time I am writing this (2021.06.14), I would not advise you installing poetry using install-poetry.py. Instead, stick with the old get-poetry.py. The new one doesn't work with pyenv. It will always create the system version instead of the version pyenv specified. The old one does not have this problem. |
It seems to work with explicit virtual env creation with: poetry env use -- $(which python)
# Creating virtualenv ...-VfhLuGbT-py3.7 in .../.cache/pypoetry/virtualenvs
# Using virtualenv: .../.cache/pypoetry/virtualenvs/...-VfhLuGbT-py3.7
Versions: poetry --version
# Poetry (version 1.2.0a1)
pyenv --version
# pyenv 2.0.1-3-g1706436f
pyenv versions
# system
# * 3.7.6 (set by PYENV_VERSION environment variable)
# 3.9.5
|
For the benefit of others who have landed on this thread looking for help with Pyenv-installed Python, there is an open pull request #4164 which seems to provide support for it. |
The new If you need to switch between environments, we recommend using the We are currently discussing ways to improve the situation so we'll keep you posted if we ever find a better solution. |
@sdispater What is the motivation behind this switch? |
@sdispater Is pip installing poetry for development still not recommended? I usually create a pyenv virtualenv for each project to using the script on each one of them is going to be a real annoyance, but I could see myself just pip installing poetry on each venv. |
@nzhwtq What motivated us to make the switch was to alleviate maintenance burden and also for security (the vendored dependencies were frozen so fixing dependencies required us to make a new release which was less than ideal). While I understand that the convenience of having one installation of Poetry for any pyenv environment will be missed I think this is for the best. @albireox I wouldn't say that installing via |
@sdispater Thank you for the explanation. For now with the new installer, if I installed it with the system python, when the system python upgraded, will poetry change its default virtual environment python version for the new project? If so, I assume the best practice has become using pyenv to change to the desired python version and install poetry rather than install it beforhand using the system python? |
Installing poetry with |
Just in case someone end up here after hours debugging do the usual flow then |
Thanks @princelySid. That would be |
Seconding this as of the time of this writing. |
This is all getting pretty confusing. Perhaps the doc should spell out how to install & use poetry in the common python cases: (a1) regular python installer, (a2) regular installer + virtualenv, (b1) pyenv, and (b2) pyenv + virtualenv. |
Still same issue as of this comment. |
At the time of writing (2022.07.26), I can still replicate the same behaviour. Please fix it. |
poetry == 1.1.14
|
After many hours confusion I realize I am facing this problem :( |
As of 1.2, I am going to lock this issue for now as it is solved, and people attempting to get support in it will be sending a lot of unnecessary notifications. |
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
OS version and name: MacOS 10.14 Mojave
Poetry version: 0.12.8
Issue
I have a project directory with a
.python-version
file like this:Poetry has been installed into Python 3.6.5. According to recent comments, poetry is supposed to detect the active Python version when creating a new virtual environment, but it seems to stick with 3.6.5 all the time. To illustrate:
When I specify
python = "^3.7"
in `pyproject.toml I get an error:The text was updated successfully, but these errors were encountered: