I made a poetry-based project on Manjaro, where python3 is the default.
On another machine, which has Ubuntu 18.04, I wanted to re-create the virt. env. but I got the following error:
$ poetry install
/home/jabba/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
[RuntimeError]
The current Python version (2.7.15) is not supported by the project (^3.6)
Please activate a compatible Python version.
Under my Ubuntu python points to Python 2.7, it's true, but Ubuntu has a python3 symlink that points to Python 3.6.
I think poetry should pick Python 3 automatically. But anyway, how can I create a Python 3 virt. env. in this case? Thanks.
I even tried this trick:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
Notice "python3" at the end, but it didn't solve my problem. I still get the same error, i.e. it's still using Python 2.7.
@jabbalaci you can create a virtualenv manually, activate it and then poetry will use that one. E.g.
python3 -mvenv ./.venv
./.venv/bin/activate
poetry ...
@pmav99 Thanks, but it's a workaround solution. If poetry wants to be better than pipenv, then it should just work out of the box.
OK, I found a way (using https://github.com/sdispater/poetry/issues/721):
Install with Python 3:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
Then edit the file ~/.poetry/bin/poetry and change the first line to:
#!/usr/bin/env python3
That is, python is changed to python3.
The bad news is that if you update poetry to a new version, this change will be overwritten very likely.
Thanks for this solution.
It solved my issue similar to the #1257.
Thanks @jabbalaci fixed my issue too.
I think this is essentially a duplicate of #721
@matthijskooijman Previously, I put a reference on https://github.com/sdispater/poetry/issues/721 .
this workaround is not working for me on ubuntu 18.04
@danieleades Did you install it with python3? Notice that I have python3 at the end of this line:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
Under Ubuntu, python points to Python 2.
@jabbalaci yep.
For the record, installing using pipx is probably much easier...
And this does not apply just to poetry but to any python utility that doesn't exist in the repos (and/or is outdated)
Hello @ all,
I'm closing this issue, because the original issue is resolved in poetry 1.0.
If poetry is installed with python2 and a pyproject.toml defines python3 as a dependency, poetry will try to find python3 for creating the venv. The same the other way round.
Furthermore, you can set the python executable, to use for the venv, with the new env subcommand, e.g. poetry env use python3.
More information are available in the docs.
Hi @finswimmer i've just tested this on ubuntu-
the same issue occurs if poetry is installed using python3, however the workaround now works (namely changing the shebang in /bin/poetry to "python3").
I don't think its fair to say the issue is completely resolved.
I didn't test installing with python2, it's practically 2020 after all ;)
I faced the same issue when I try to install poetry on clean Ubuntu 18.04 as it does not install built-in python (2.x). By using the workaround (#!/usr/bin/env python3), I still could not use the poetry with the error messages on this issue.
~The issue is still very prevalent on Ubuntu 19.10, so I don't think so it's wise closing this issue yet. I tried @jabalacci's workaround, it installs fine but when I try checking if it installed properly using the poetry --version command, I get a poetry: command not found error.~
~Please look into it.~
EDIT: Don't be a fool like me & jump to conclusions, curl it & when the download completes, make sure you run the source $HOME/.poetry/env command. Then check it using poetry --version.
Also: I think the problem reported in this issue has been fixed. If you run into new issues that happen to be on Ubuntu, better to open up a new issue (or look at other existing issues, such as #721 or #1837).
Most helpful comment
OK, I found a way (using https://github.com/sdispater/poetry/issues/721):
Install with Python 3:
Then edit the file
~/.poetry/bin/poetryand change the first line to:That is,
pythonis changed topython3.The bad news is that if you update poetry to a new version, this change will be overwritten very likely.