-vvv option).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.
It also fails to create the virtual environment. My current config is as follows:
cache-dir = "~/Library/Caches/pypoetry"
experimental.new-installer = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs" # ~/Library/Caches/pypoetry/virtualenvs
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.
The shebang for poetrylooks like this:
#!/usr/bin/env python
Which means, poetry itself will run with any python to which python points at the time of running. Doing this makes a smooth integration of pyenv possible. Your project needs python3.6? pyenv shell 3.7.5 followed by a poetry init -n and poetry install and you are done. You need a python2? pyenv shell 2.7.15 followed by a poetry init -n and poetry install and you are done. Having a #!/usr/bin/env python3 would prevent to switch to python2 this way.
Furthermore having #!/usr/bin/env python indicates that poetry don't care with which version of poetry it runs exactly. At the moment it supports python2 and 3. The only real disadvantage about it is on the developer site ;)
With the next feature release we will drop python2 support. And I'm pretty sure we will then hardcode the shebang to python3. Until then the installer is smart enough to detect if you have a python or not. If you have one, it writes this to the shebang as it asumes, that's the python you prefer. If there is no python it will try python3 first and then python2
@pedrorrivero : Please be so kind to open a different issue for this and describe what happens.
fin swimmer
When you say installer, are you taking abut get-poetry.py? Because last time I checked the shebang ended up being plain python regardless if I called get-poetry with python or python3.
I would also expect that if running _get-poetry.py_ with python3, python3 would be used for the shebang line. Even when I explicitly use python3 to install Poetry, I still get bothered by a big warning that Python 2 support is about to be dropped.
Sure, it's easy enough to adjust the shebang line manually, but not when installing Poetry in an automated way.
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"]
Most helpful comment
The issue here is that the poetry executable has
pythonin 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 python3instead of!/usr/bin/env pythonit will work.This is a hack and not a solution. I don't know why this is not the default behavior.