question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

poetry and pyenv don't work well together

See original GitHub issue

I am using pyenv to manage my python versions and virtualenvs. This seems to cause some problems with poetry.

>> which python
~/.pyenv/shims/python
>> which pip
~/.pyenv/shims/pip
>> poetry run which python
~/.cache/pypoetry/virtualenvs/XXXXX-py3.6/bin/python
>> poetry run which pip
~/.pyenv/shims/pip

This seems to cause the issue, that packages are installed in to the python version set by pyenv, but the python interpreter is used from the poetry virtualenv. This is no problem, when I activate the virtualenv first and then run poetry install But if I want to rely on poetry’s automatic virtualenv management, this doesn’t work anymore.

If you need more info I’ll gladly provide it.

Thanks for your great work and tool, it’s a real pleasure to work with 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:38
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

17reactions
sdispatercommented, Jun 30, 2018

I am currently using pyenv on MacOS and I don’t have any problem making it working.

I didn’t do anything special, I only have this on my .zshrc:

# pyenv
export PYENV_ROOT=/usr/local/var/pyenv

if [[ -z "$VIRTUAL_ENV" ]]; then
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
fi
10reactions
anprcommented, Apr 29, 2019

Just to give my feedback here, I’m new to poetry and encountered issues when using pyenv and poetry together. Basically, it installed packages to a newly created virtualenv directory that was then nowhere to be found, poetry shell didn’t work, etc.

I installed poetry using curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python. My python used there is python 3.7.1 from ~/.pyenv/shims/python. Then I went to my code repository, activated my pyenv virtualenv, executed poetry install and had the problems mentioned above.

I’m just commenting here, because I believe there is some underlying issue here that’s not fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry does not use active pyenv when creating virtual ...
I'll do some debugging - I'm having trouble locating the code where poetry detects the Python version, once I find where that is...
Read more >
Using Poetry with PyEnv and having Python version issues
I can do a pyenv local 3.10.0 without any issue and the project uses it. But using the poetry env use command errors...
Read more >
Get started with pyenv & poetry. Saviours in the python chaos!
Organise your python chaos with pyenv and poetry. This post shows how to set it up and some basic examples to get started....
Read more >
Modern Python part 1: start a project with pyenv & poetry
We are going to see here how to use two of them: Pyenv, to manage and install different Python versions, and Poetry, to...
Read more >
Starting with pyenv & poetry for Python development - Medium
Pyenv : This is a python environment manager, allows to install and run off multiple python installations on the same machine.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found