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.

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:closed
  • Created 5 years ago
  • Reactions:55
  • Comments:45 (9 by maintainers)

github_iconTop GitHub Comments

39reactions
harrybiddlecommented, Mar 18, 2019

This is also a problem on “out-of-the-box” macOS, where python is 2.7.15. … Which is pretty bad because trying to poetry install on a modern project fails with:

[RuntimeError]
The current Python version (2.7.15) is not supported by the project (^3.7)
Please activate a compatible Python version.

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.

34reactions
jeking3commented, Mar 8, 2019

I abandoned use of it for now. When it doesn’t fail less than 5 minutes into use, I’ll be back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3 Installation & Setup Guide
The first step to getting started with Python is to install it on your machine. In this tutorial, you'll learn how to check...
Read more >
Installing Packages - Python Packaging User Guide - Python.org
Requirements for Installing Packages. Ensure you can run Python from the command line. Ensure you can run pip from the command line ·...
Read more >
Python 3 Installation & Setup Guide - Will Vincent
How to install Python on Windows/macOS/Linux/Chromebook.
Read more >
Properly Installing Python - The Hitchhiker's Guide to Python
These guides go over the proper installation of Python for development purposes, as well as setuptools, pip and virtualenv. Python 3 Installation Guides¶....
Read more >
Installing Python 3 on Windows
First, follow the installation instructions for Chocolatey. ... All supported versions of Python 3 include pip, so just make sure it's up to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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 Hashnode Post

No results found