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.

poetry default to using python instead of python3

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • [n/a ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: macOS big sur

  • Poetry version: 1.1.2

  • python3.8 installed with home-brew

Issue

when creating a new project with poetry it sets the python version as python 2.7 by default rather than using the latest available version.

It also ironically prints the warning:

Python 2.7 will no longer be supported in the next feature release of Poetry (1.2).
You should consider updating your Python version to a supported one.

Note that you will still be able to manage Python 2.7 projects by using the env command.
See https://python-poetry.org/docs/managing-environments/ for more information.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:16
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
ericriffcommented, Oct 13, 2020

The issue here is that the poetry executable has python in its shebang, which is annoying. I don’t remember exactly where it gets installed, but lets say it is /usr/bin/poetry, you can get this path with $ which poetry. If you edit the shebang in that executable and replace it with !/usr/bin/env python3 instead of !/usr/bin/env python it will work.

This is a hack and not a solution. I don’t know why this is not the default behavior.

4reactions
brechtmcommented, Oct 23, 2020

How about simply changing the following line in get-poetry.py

allowed_executables = ["python", "python3"]

to

allowed_executables = ["python3", "python"]

This first tries Python 3, which doesn’t spit out a big warning message. In fact, this is how it is done for Windows:

allowed_executables += ["py.exe -3", "py.exe -2"]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Change python version to 3.x - Stack Overflow
The default python will end up in the pyproject.toml file and you'll need ... You could also use poetry new instead of poetry...
Read more >
Introduction | Documentation | Poetry - Python dependency ...
Poetry is a tool for dependency management and packaging in Python. ... Note: On some systems, python may still refer to Python 2...
Read more >
How To Install Poetry to Manage Python Dependencies on ...
Poetry is a dependency manager for Python that is also capable of building and packaging your Python projects for distribution.
Read more >
Configure a Poetry environment | PyCharm Documentation
To use Poetry in PyCharm, you need to install it on your machine and create a specific Python ... curl -sSL https://install.python-poetry.org |...
Read more >
Dependency Management With Python Poetry
When your Python project relies on external packages, you need to make sure you're using the right version of each package.
Read more >

github_iconTop Related Medium Post

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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found