poetry: Ubuntu 22.04, Python 3.10, and broken virtual environment layouts
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: Ubuntu Jammy
-
Poetry version: 1.2.0
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/colindean/27d36dcc7cf78f722f374ebd5bfd970f (also contains log output and a brief description of env setup steps)
Issue
root@80d0e404badc:/what# poetry self add poetry-plugin-bundle
Using version ^1.0.0 for poetry-plugin-bundle
Updating dependencies
Resolving dependencies... (3.8s)
[Errno 2] No such file or directory: 'python'
I believe the problem is in here:
Ubuntu doesn’t provide a python
command anymore, just python3
:
root@80d0e404badc:/what# python --version
bash: python: command not found
root@80d0e404badc:/what# python3 --version
Python 3.10.4
Seeing as though all supported versions of Python on which Poetry runs should also provide a python3
executable, perhaps the fallback here should be python3
?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 20 (15 by maintainers)
Commits related to this issue
- Add work-a-round for "poetry install" bug See: * https://github.com/python-poetry/poetry/issues/5490#issuecomment-1312811998 * https://github.com/python-poetry/poetry/issues/6371 — committed to boxine/bx_django_utils by deleted user 2 years ago
- Add work-a-round for "poetry install" bug See: * https://github.com/python-poetry/poetry/issues/5490#issuecomment-1312811998 * https://github.com/python-poetry/poetry/issues/6371 — committed to jedie/cookiecutter_templates by jedie 2 years ago
- Add work-a-round for "poetry install" bug See: * https://github.com/python-poetry/poetry/issues/5490#issuecomment-1312811998 * https://github.com/python-poetry/poetry/issues/6371 — committed to jedie/django_example by jedie 2 years ago
- Modernize project setup Use https://github.com/jedie/manageprojects and the CookieCutter Template: https://github.com/jedie/cookiecutter_templates/tree/main/poetry-python to modernize the project set... — committed to boxine/bx_py_utils by deleted user 2 years ago
- Modernize project setup Use https://github.com/jedie/manageprojects and the CookieCutter Template: https://github.com/jedie/cookiecutter_templates/tree/main/poetry-python to modernize the project set... — committed to boxine/bx_py_utils by deleted user 2 years ago
I found that installing Debian’s
python3-poetry
results in a perfectly working Poetry. Looking at https://sources.debian.org/src/poetry/1.3.2%2Bdfsg-3/debian/patches/ I don’t believe this is because they’ve patched Poetry themselves.I also ran into this problem and didn’t know about the
DEB_PYTHON_INSTALL_LAYOUT=deb
workaround so will try that now. On my digging I may have found some more useful information as I too thought it was a problem with the way poetry handles the system python but the trace suggests otherwise.The first “poetry error” (by which I don’t mean that poetry is doing anything wrong) in the trace comes from the
env_manager.create_venv()
command which, as the name suggests, creates a new venv usingpython3-venv
. When I have a look at this new venv it contains<venv_path>/share
and<venv_path>/lib
but no<venv_path>/bin
which should contain the python executables as well as thepython
symlink.This seems very weird because when I create the venv myself the bin directory does exist so I’m not sure what’s happening internally for this bin directory to not get made.
Like I say I hope this is helpful to others and helps any debugging/patching effort either here or in Ubuntu upstream. Will try the environment variable setup now
You should ideally set it before ever installing Poetry – however, I am reasonably sure that setting it during env creation (e.g.
poetry env use
,poetry add
without an existing env, etc) and during subsequentpoetry install
/poetry add
/poetry update
) should be sufficient. I do not work regularly with a Ubuntu/Debian distro, so I am guessing to an extent (I just export it in.bashrc
when it comes up).N.b. I hadn’t even run
poetry install
yet and just now went I did…