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

poetry install didn't find the correct python version set by pyenv #9619

Closed
doyaklee opened this issue Aug 10, 2024 · 4 comments
Closed

poetry install didn't find the correct python version set by pyenv #9619

doyaklee opened this issue Aug 10, 2024 · 4 comments
Labels
area/python Related to detection of Python installations kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@doyaklee
Copy link

Description

Hello. I'd like to use poetry to manage python packages for global python environment set by pyenv in Windows.
So, I first install and set python 3.12.5 using pyenv

> pyenv install 3.12.5
> pyenv global 3.12.5

Then, in the arbitrary folder containing pyproject.toml file with python = 3.12.5 in it, I install python packages with following commands

> poetry config virtualenvs.create false
> poetry lock
> poetry install

So far, it worked fine globally.
Problems happened when I tried to switch my global environment to 3.13.0rc1.
I try to do the same thing, but it seems that poetry install stuck to previous 3.12.5 version even though python points to 3.13.0rc1

> pyenv install 3.13.0rc1
> pyenv global 3.13.0rc1
> poetry install
## Skipping virtualenv creation, as specified in config file.
## Installing dependencies from lock file
##
## No dependencies to install or update
> python  # leads to python3.13.0rc1

How could I utilize poetry to manage global python package management with pyenv? Please give me some hints.
Thanks!

Workarounds

  1. delete the previous pyenv version using pyenv uninstall 3.12.5
  2. uninstall and reinstall poetry
  3. reinstall packages using poetry : poetry install

Poetry Installation Method

install.python-poetry.org

Operating System

Windows 10

Poetry Version

1.8.3

Poetry Configuration

cache-dir = "C:\\Users\\doyaklee\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = false
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs"  # C:\Users\doyaklee\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

cache-dir = "C:\\Users\\doyaklee\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = false
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
Platform: "win-amd64"
Python version: "3.13"
Current installation scheme: "nt"

Paths:
        data = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        include = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Include"
        platinclude = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Include"
        platlib = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Lib\site-packages"
        platstdlib = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Lib"
        purelib = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Lib\site-packages"
        scripts = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Scripts"
        stdlib = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Lib"

Variables:
        BINDIR = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        BINLIBDEST = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Lib"
        EXE = ".exe"
        EXT_SUFFIX = ".cp313-win_amd64.pyd"
        INCLUDEPY = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Include"
        LDLIBRARY = "python313.dll"
        LIBDEST = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\Lib"
        LIBDIR = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1\libs"
        LIBRARY = "python313.dll"
        Py_GIL_DISABLED = "0"
        SOABI = "cp313-win_amd64"
        TZPATH = ""
        VERSION = "313"
        VPATH = "..\.."
        abi_thread = ""
        abiflags = ""
        base = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        exec_prefix = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        implementation = "Python"
        implementation_lower = "python"
        installed_base = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        installed_platbase = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        platbase = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        platlibdir = "DLLs"
        prefix = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        projectbase = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        py_version = "3.13.0rc1"
        py_version_nodot = "313"
        py_version_nodot_plat = "313"
        py_version_short = "3.13"
        srcdir = "C:\Users\doyaklee\.pyenv\pyenv-win\versions\3.13.0rc1"
        userbase = "C:\Users\doyaklee\AppData\Roaming\Python"

Example pyproject.toml

[tool.poetry]
package-mode = false 

[tool.poetry.dependencies]
python = "3.12.5"    
pip = "^24.0.0"
pipdeptree = "*"
graphviz ="*"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Poetry Runtime Logs

It's not failed.
@doyaklee doyaklee added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Aug 10, 2024
@dimbleby
Copy link
Contributor

poetry config virtualenvs.create false

Don't do that

@doyaklee
Copy link
Author

poetry config virtualenvs.create false

Don't do that

What I want to do is to install dependencies into the system environment, and as I understand, this is what exactly virtualenvs.create false intended as written in the documentation. So, I can't understand why I shouldn't do that

If set to false, Poetry will not create a new virtual environment. If it detects an already enabled virtual environment or an existing one in {cache-dir}/virtualenvs or {project-dir}/.venv it will install dependencies into them, otherwise it will install dependencies into the systems python environment.

@dimbleby
Copy link
Contributor

What I want to do is to install dependencies into the system environment

No, you don't want to do that.

If you insist on pursuing this, you can check how poetry determines the "system" environment here, and figure out what it is doing. I guess it is using the-python-that-poetry-itself-was-installed-with.

But I highly recommend just not doing what you are doing.

@Secrus Secrus added the area/python Related to detection of Python installations label Oct 13, 2024
@finswimmer
Copy link
Member

I agree with @dimbleby. Don't do this.

If you really want to do this, you have to set virtualenvs.prefer-active-python to true (https://python-poetry.org/docs/configuration/#virtualenvsprefer-active-python-experimental). Otherwise Poetry will use the Python it was installed with

@finswimmer finswimmer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/python Related to detection of Python installations 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

4 participants