poetry: Problem vendoring subprocess32 in Ubuntu
-
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). -
Ubuntu 16.04/18.04:
Issue
I’m building a Dockerfile and am seeing a RuntimeWarning after running any poetry command that works with the venv. Since I’m using poetry to run a web server (gunicorn), I’m worried that this could have a negative impact on app performance. I haven’t seen this before, so it appears to have been introduced recently?
The warning:
/root/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
I installed poetry using the get-poetry.py
script, and have even updated to the latest version. Here is the Dockerfile that I’m using, and the relevant output:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
htop \
python \
python-dev \
wget
RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
ENV PATH=$PATH:/root/.poetry/bin
RUN poetry self:update --preview
RUN poetry version
And the output for the final command…
$: poetry version
/root/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
[ImportError]
No module named pkg_resources
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 26
- Comments: 27 (8 by maintainers)
I’m having same issue, Debian current, Python 3.7.4
Editing ~/.poetry/bin/poetry and changing “/usr/bin/env python” to “/usr/bin/env python3” fix it, but this will be probably overridden after next self:update
Shouldn’t we use?
#!/usr/bin/env python3
I don’t know if we should use a fallback version to python2 but seems reasonable to support python3 only.
With Ubuntu 20.04 released, which does not include python 2.7 by default, this issue should be even more pressing.
@adamwojt My apologies. My comment was not meant to be read as harsh. Yes, many distro have not updated to just using solely Python 3 and some even have really valid reasons for not making the jump. However, running Python 2 is a bad thing™ since no updates will be happening.
@kierun It’s easy to say that but poetry entry point uses:
#!/usr/bin/env python
Which in most distros still means python 2.7 .Thanks. This helped.
This is more of a people problem though. My workplace experience has been that co-workers are very distrustful of new tools when they give a warning on a fresh install.
Poetry is a wonderful tool, but the warning does make it harder to sell it to new people.
I’ve done some more investigating on the root cause - why the
import _posixsubprocess32
fails. It appears the SO is built with a Python version that was compiled with UCS2 support, whereas my version is compiled with UCS4.I’m running this snippet to confirm what my Python was compiled with:
This is a tricky one to get around, really. You’d have to ship maybe another SO that’s compiled for UCS4 and then modify the original
subprocess32.py
to import that if the original import failed or so. Or you’d need to compile that dependency on the end-user’s machine.Alternatively, you could use Python 3, which avoids these problems altogether (by virtue of not needing this SO at all).
I am getting this under latest ubuntu 18 under windows WSL. When installing, I used a python 3.7 version to run it, which came from pyenv.
I personally found installing poetry using pipx was an easy workaround (inspired by https://github.com/python-poetry/poetry/issues/1543#issuecomment-569709218).
That way poetry’s dependencies are restricted to a virtualenv, but it sticks with python3.
Just got to remember to
pipx upgrade poetry
rather than a self update.I don’t dev in Python 2, and try not to use projects that are written in Python 2, …unless there is a very good reason to do so. Even then, I would want to port any projects that are in 2, to 3, if I would end up using them long term… …as I am currently only working with 3.
But I am using Debian 10…and I like Debian distro a lot. At this time I don’t think it would be appropriate to switch distros just because they haven’t upgraded to Python 3.
Debian lags behind… but whatever–I like it quite a bit.
…anyways…
Hello,
the warning about
_posixsubprocess
is just a warning and has no influence on the correct working ofpoetry
.As
poetry
can run with python2 and python3 it assumes, that whatever is linked the topython
executable, is the preferred version by the user. With https://github.com/python-poetry/poetry/pull/1878, which will be included in the 1.1 release, the installer script will be able, to addpython3
to the shebang if there is nopython
on the system. (Which is allowed by PEP397, but personally I would call it a broken system).@brizzbane Python 2 is deprecated and should not be used.