Poetry: Setting python env fails

Created on 11 Dec 2020  ·  5Comments  ·  Source: python-poetry/poetry

  • [x ] I am on the latest Poetry version.
  • [x ] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: archlinux from aur
  • Poetry version: 1.0.10
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

~/D/c/l/r/h/i/inference-image (develop|✔) 🔥🔥 poetry env use /home/magnus/.pyenv/versions/3.8.5/bin/python
Creating virtualenv inference-NAwQdqdj-py3.8 in /home/magnus/.cache/pypoetry/virtualenvs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'PosixPath' is not defined
Using virtualenv: /usr
Bug Triage

Most helpful comment

~/D/c/l/r/h/training (develop|…) 🔥🔥 poetry env use /home/magnus/.pyenv/versions/3.8.5/bin/python
Creating virtualenv training-9MFdeoy7-py3.8 in /home/magnus/.cache/pypoetry/virtualenvs
Using virtualenv: /home/magnus/.cache/pypoetry/virtualenvs/training-9MFdeoy7-py3.8

This indeed works now, thanks!

All 5 comments

You checked the box saying you are on the latest poetry version, but then say you are on _1.0.10_. Do you want to stay on _poetry 1.0_, or could you update to _1.1_?

Is that the full stack trace?

Based on the language of poetry env use --help, I would take a guess that poetry env use is not meant to do what you're looking for. Here are some suggestions/observations...

  1. Poetry will respect existing virtual environments, unless you tell it not to. It seems like poetry env use will override the $VIRTUAL_ENV variable.
  2. It also seems like poetry env use will only create or activate poetry managed virtual environments.
  3. I see you're using pyenv. You can create and activate virtual environments with pyenv and configure poetry to not create or manage virtual environments at all. This is the workflow that I've found works best for me.

Also, the NameError: name 'PosixPath' is not defined issue was resolved here #2711. I'd suggest upgrading poetry to get the fix.

Indeed looks like it is a duplicate of https://github.com/python-poetry/poetry/issues/2711 and ticket could probably be closed.

Hello,

so first of all, my bad seems like Archlinux poetry is outdated, sorry for that.

For the env usage I was told to do so here: https://github.com/python-poetry/poetry/issues/3342#issuecomment-724198784
at least that is my interpretation of that comment.

~/D/c/l/r/h/training (develop|…) 🔥🔥 poetry env use /home/magnus/.pyenv/versions/3.8.5/bin/python
Creating virtualenv training-9MFdeoy7-py3.8 in /home/magnus/.cache/pypoetry/virtualenvs
Using virtualenv: /home/magnus/.cache/pypoetry/virtualenvs/training-9MFdeoy7-py3.8

This indeed works now, thanks!

Was this page helpful?
0 / 5 - 0 ratings