Include installation instructions for python3
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
Issue
The README states as the ideal way to install Poetry:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
But, on an Ubuntu Xenial system with only Python 3 installed, this leads to the error bash: python: command not found
. If I simply pipe the curl command through python3
instead then it succeds, but then I get:
$ poetry install
/usr/bin/env: 'python': No such file or directory
This is because the top of the installed file at $HOME/.poetry/bin/poetry
contains #! /usr/bin/env python
.
If, instead, I install poetry with pip3 install poetry
, then head -n 1 $(which poetry)
shows #!/usr/bin/python3
at the top of the file, which works perfectly.
Ubuntu, from 18.04 Xenial onwards, includes only Python 3 by default. And the minimal version of Xenial doesn’t come with Python out of the box at all.
If you install Python 3 on Ubuntu, the binary that’s installed is python3
. python
doesn’t exist unless you’ve also installed Python 2. This deliberately follows PEP 394:
- python2 will refer to some version of Python 2.x.
- python3 will refer to some version of Python 3.x.
- for the time being, all distributions should ensure that python refers to the same target as python2.
- however, end users should be aware that python refers to python3 on at least Arch Linux (that change is what prompted the creation of this PEP), so python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3.
- in preparation for an eventual change in the default version of Python, Python 2 only scripts should either be updated to be source compatible with Python 3 or else to use python2 in the shebang line.
Although the PEP states “python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3” I’m not sure that this is compatible with the statement “all distributions should ensure that python refers to the same target as python2”, because this means that if a system doesn’t have Python 2 then the python
binary won’t exist. I think scripts have to do their best to use python3
if they know it’s supported, and most I’ve encountered do.
I think maybe it would be good if the suggested install command was:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | ( python3 || python )
Or maybe you could provide a bash script (if you can rely on bash
being available on all relevant systems) so that you could hide the logic of determining the Python version from the user:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.sh | bash
Or simply say in the README:
One of:
``` bash
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
# or
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
And that the script would set up the poetry
binary with either #! /usr/bin/env python3
for Python 3, or #! /usr/bin/env python
for Python 2 (which would then allow for the possibility of python
changing to Python 3 at some point).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:55
- Comments:45 (9 by maintainers)
Top GitHub Comments
As a first-time poetry user I ran into exactly this! When you search the documentation and past issues, the answer you always recieve is “just use pyenv”.
But I think this places an unnecessary restriction: it basically means you can’t use poetry for a modern Python project unless you also commit to (a) using pyenv, (b) manually changing the shebang of poetry yourself, or © running poetry within a Python3 virtual environment. Pipenv behaves better here: if Python 3 is required for the project it’ll find it if it’s installed and use it.
Sure, we could argue that this is out of the scope of poetry, but it’s one of the first issues I hit and I’m sure others will too.
I abandoned use of it for now. When it doesn’t fail less than 5 minutes into use, I’ll be back.