-vvv
option).When I try the following command,
poetry env use 3.8
it will fail with the following message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'PosixPath' is not defined
I guess this is caused by the following line.
https://github.com/python-poetry/poetry/blob/d3c9049a18ae33baacfcb5c698777282f2f58128/poetry/utils/env.py#L625
Variable venv
is a Path
object, and it is finally passed to str.format()
https://github.com/python-poetry/poetry/blob/d3c9049a18ae33baacfcb5c698777282f2f58128/poetry/utils/env.py#L672
Then CREATE_VENV_COMMAND
is
https://github.com/python-poetry/poetry/blob/d3c9049a18ae33baacfcb5c698777282f2f58128/poetry/utils/env.py#L105-L106
$ python -c 'import pathlib; print("{!r}".format(pathlib.Path("/")))'
PosixPath('/')
So the interpreter will first read a line like path = PosixPath('...')
but PosixPath
is not defined.
I think this bug is introduced in 1.0.10 https://github.com/python-poetry/poetry/commit/54870697d921ae6efdbba0bc86f6b54c86d6896a
I guess it will be fixed by replacing venv
to str(venv)
so I tried to fix, but the commit above is replacing str(venv)
to venv
and I can't understand the purpose to do so. I can't fix it.
Thanks.
version 1.1.0a3 not include 5487069 https://github.com/python-poetry/poetry/blob/a50d87dbdcd539499ce7e5c7e9149a491505af52/poetry/utils/env.py#L664
So workaround is installing preview version.
@elferia appreciate the bug report and the analysis. As you have already identified, the preview version will resolve this. And since we recently released the last 1.0.z
release and next release is expected soon, resolving this.
I had the same issue, upgrading to the latest preview version fixed it for me - thanks!
$ poetry self update --preview
Updating to 1.1.0b2
Thanks @alexlouden
I had to do : pip install --user --pre poetry -U
Since my poetry installation gave me this warning: Poetry was not installed with the recommended installer. Cannot update automatically.
Thanks @tony
if you're using pipx
as install manager, you can get pre-release by : pipx install --pip-args='--pre' poetry
(confimred working)
or upgrade exisiting one pipx install --pip-args='--pre -U' poetry
(haven't tried this one, but might work)
pipx install --pip-args='--pre -U' poetry
I had to use this instead:
pipx upgrade --pip-args='--pre' poetry
Still running into this issue when doing poetry shell
on mac latest stable, works on preview 1.1.0rc1.
@gavinbeatty https://github.com/python-poetry/poetry/issues/2711#issuecomment-663499610
Most helpful comment
I had the same issue, upgrading to the latest preview version fixed it for me - thanks!