Skip to content

Poetry does not use pyenv virtualenvs #5956

@simonmeggle

Description

@simonmeggle
  • 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: Mac OS arm64 (M1)

  • Poetry version: 1.1.13

Issue

I have installed poetry with curl -sSL https://install.python-poetry.org | python3 - and it is located in /Users/simon/.poetry/bin/poetry.

I want poetry to install the dependencies into the current virtual environment.

My poetry config:

❯ poetry config --list
cache-dir = "/Users/simon/Library/Caches/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/simon/Library/Caches/pypoetry/virtualenvs

My pyproject.toml:

❯ cat pyproject.toml
[tool.poetry]
name = "testproject"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.10"
robotframework = "5"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
# Homebrew default python 
❯ python -V
Python 2.7.18
❯ mkdir testproject && cd $?
# create a venv with python 3.10.5
❯ pyenv virtualenv 3.10.5 venv-testproject
# stick this environment to this project
❯ pyenv local venv-testproject
❯ python -V
Python 3.10.5
❯ which poetry
/Users/simon/.poetry/bin/poetry
❯ poetry --version
Poetry version 1.1.13
# now try to install the dependencies into the active venv
❯ poetry install -vvv
Creating virtualenv testproject-zM3EHoG7-py3.10 in /Users/simon/Library/Caches/pypoetry/virtualenvs
Using virtualenv: /Users/simon/Library/Caches/pypoetry/virtualenvs/testproject-zM3EHoG7-py3.10
Installing dependencies from lock file

Finding the necessary packages for the current system

Package operations: 1 install, 0 updates, 0 removals

  • Installing robotframework (5.0): Downloading... 100%
  • Installing robotframework (5.0): Installing...
  • Installing robotframework (5.0)
...
...

And here we are. All the blogs and tutorials I have read so far tell me that poetry should use the currently active venv.
But instead, it creates another virtualenv in /Users/simon/Library/Caches/pypoetry/virtualenvs/.

I also discovered the fact that poetry installed by Homebrew does not work because it has a hardcoded Python3.9 interpreter.
Poetry is now installed as recommended - but it does not want to play with pyenv's virtualenvs.

Any clue what is wrong here?
Thanks & regards,
Simon

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/external-issueIssue is caused by external project (platform, dep, etc)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions