poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Ubuntu 20.04 without python-as-python3 apt package errors No such file or directory: 'python'

Open christopherpickering opened this issue 5 years ago β€’ 26 comments

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Ubuntu 20.04
  • Poetry version: 1.1.8

Issue

Attempting to run any poetry commands results in

Installing dependencies

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700β”‚                     else:
      1701β”‚                         err_filename = orig_executable
      1702β”‚                     if errno_num != 0:
      1703β”‚                         err_msg = os.strerror(errno_num)
    β†’ 1704β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705β”‚                 raise child_exception_type(err_msg)
      1706β”‚ 
      1707β”‚ 
      1708β”‚         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700β”‚                     else:
      1701β”‚                         err_filename = orig_executable
      1702β”‚                     if errno_num != 0:
      1703β”‚                         err_msg = os.strerror(errno_num)
    β†’ 1704β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705β”‚                 raise child_exception_type(err_msg)
      1706β”‚ 
      1707β”‚ 
      1708β”‚         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700β”‚                     else:
      1701β”‚                         err_filename = orig_executable
      1702β”‚                     if errno_num != 0:
      1703β”‚                         err_msg = os.strerror(errno_num)
    β†’ 1704β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705β”‚                 raise child_exception_type(err_msg)
      1706β”‚ 
      1707β”‚ 
      1708β”‚         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
Env Info:

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700β”‚                     else:
      1701β”‚                         err_filename = orig_executable
      1702β”‚                     if errno_num != 0:
      1703β”‚                         err_msg = os.strerror(errno_num)
    β†’ 1704β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705β”‚                 raise child_exception_type(err_msg)
      1706β”‚ 
      1707β”‚ 
      1708β”‚         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

In ubuntu 20.04 there is not "python" command, only "python3". If I install sudo apt-get install python-is-python3, then poetry starts to work again.

It would be nice if poetry picked python3 if there is no python instead of failing. There is a python installed.

christopherpickering avatar Aug 20 '21 15:08 christopherpickering

Hello @christopherpickering,

how did you install poetry?

fin swimmer

finswimmer avatar Aug 20 '21 15:08 finswimmer

Hi @finswimmer, heres how:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(which python3) -

It installs fine.

christopherpickering avatar Aug 20 '21 17:08 christopherpickering

Thanks for your response! I'm able to reproduce it. It seems to be due to a change in poetry 1.1.8. I have no problems with 1.1.7. I guess https://github.com/python-poetry/poetry/issues/4414 is somehow related.

finswimmer avatar Aug 20 '21 17:08 finswimmer

I have this issue as well

luisacabs-out avatar Aug 23 '21 09:08 luisacabs-out

I can confirm this too in Alpine 3.13.5. I didn't lock poetry to a specific version in our build pipeline and started seeing the following error:

+ poetry install

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.8/subprocess.py:1704 in _execute_child
      1700β”‚                     else:
      1701β”‚                         err_filename = orig_executable
      1702β”‚                     if errno_num != 0:
      1703β”‚                         err_msg = os.strerror(errno_num)
    β†’ 1704β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1705β”‚                 raise child_exception_type(err_msg)
      1706β”‚ 
      1707β”‚ 
      1708β”‚         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

Poetry is installed into the Alpine image using pip3. Pinning it using pip3 install poetry==1.1.7 resolved the issue. Alpine (as well as the Ubuntu version listed above) do not create a symbolic link from python->python3.x and it seems 1.1.8 somehow introduced spawning the interpreter by that name in a subprocess call.

SumGR avatar Aug 23 '21 17:08 SumGR

Same problem on Centos 8 since the release of 1.1.8

wouterdb avatar Aug 24 '21 10:08 wouterdb

Same issue on DietPi v7.5 (Debian Bullseye), adding an alias for python to python3 does not resolve either.

EthanC avatar Aug 24 '21 23:08 EthanC

Same issue on my Linux mint 20

jd-solanki avatar Aug 25 '21 02:08 jd-solanki

The same problem shows up in older Ubuntu 18.04 (bionic), but there's no python-is-python3 package as workaround on bionic. Also things like alias python="python3.6" do not fix the issue.

nicolashainaux avatar Aug 25 '21 15:08 nicolashainaux

I think I have the same on an Alpine docker container with Python 3.6 and Poetry 1.1.8 installed:

$ poetry add pandas

  FileNotFoundError

  [Errno 2] No such file or directory: 'python': 'python'

  at /usr/lib/python3.6/subprocess.py:1364 in _execute_child
      1360β”‚                     if errno_num != 0:
      1361β”‚                         err_msg = os.strerror(errno_num)
      1362β”‚                         if errno_num == errno.ENOENT:
      1363β”‚                             err_msg += ': ' + repr(err_filename)
    β†’ 1364β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1365β”‚                 raise child_exception_type(err_msg)
      1366β”‚
      1367β”‚
      1368β”‚         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,

Installing Poetry 1.1.7 instead leads to:

$ poetry add pandas
Creating virtualenv pandas-il7asoJj-py3.6 in /root/.cache/pypoetry/virtualenvs
Using version ^1.3.2 for pandas

Updating dependencies
Resolving dependencies... (0.0s)

  AssertionError



  at /usr/lib/python3.6/site-packages/poetry/mixology/incompatibility.py:111 in __str__
      107β”‚         )
      108β”‚
      109β”‚     def __str__(self):
      110β”‚         if isinstance(self._cause, DependencyCause):
    β†’ 111β”‚             assert len(self._terms) == 2
      112β”‚
      113β”‚             depender = self._terms[0]
      114β”‚             dependee = self._terms[1]
      115β”‚             assert depender.is_positive()

Not knowing what the latter is about, but the python error has obviously gone when using Poetry 1.1.7 instead of Poetry 1.1.8.

lorenzznerol avatar Aug 30 '21 19:08 lorenzznerol

Might be a little bit irrelevant but I want to ask, is there any way to change the Python version used by Poetry in Linux (particularly Ubuntu)?

I wrote some scripts using Python 3.9 and pyproject.toml list it as a dependency. In Linux, I can download the unofficial version of Python 3.9 from ppa:deadsnakes/ppa. (Default Python 3 is 3.8) However, I have no idea how to set Poetry to use it.

regunakyle avatar Aug 31 '21 16:08 regunakyle

@regunakyle: poetry env use /path/to/python is what you are looking for: https://python-poetry.org/docs/master/managing-environments/#switching-between-environments

finswimmer avatar Sep 01 '21 04:09 finswimmer

Windows 10 with Ubuntu 20.04 WSL - same issue. With version 1.1.8 every poetry command fails with /usr/bin/env: β€˜python\r’: No such file or directory

Installing older version solves this for me.

# wget https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py
# python3 install-poetry.py --version 1.1.7

tomaski avatar Sep 10 '21 12:09 tomaski

I have the same problem with poetry 1.1.8 in my Zorin 16 (ubuntu 20.04 and python 3.8). I Installed poetry using:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -

I can run "poetry --version", "poetry check", "poetry init", but "poetry shell" and "poetry debug" are pretty much useless. The error i get is:

$ poetry debug

Poetry
Version: 1.1.8
Python:  3.8.10

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

I have not found any working fixes yet.

pkfkmkz avatar Sep 12 '21 03:09 pkfkmkz

I'm seeing this on Debian (unstable) too.

I installed Poetry with:

$ mkdir /tmp/poetry-venv
$ python3 -m venv /tmp/poetry-venv
$ /tmp/poetry-venv/bin/python3 -m pip install wheel
$ /tmp/poetry-venv/bin/python3 -m pip install poetry

Thing is, while /usr/bin/python does not exist, /tmp/poetry-venv/bin/python does exist (as a symlink to python3 in the same directory).

If I explicitly put the venv into the PATH, then poetry works fine (i.e., invoke it as PATH=/tmp/poetry-venv/bin:$PATH python3 -m poetry). So it looks to me like Poetry is trying to shell out to python, which will fail if either:

  • python is not in the PATH
  • the Python interpreter that launched Poetry is not called python.

I think Poetry should instead use sys.executable which will work in either of the above cases:

$ /tmp/poetry-venv/bin/python3 -c 'import sys; print(sys.executable)'
/tmp/poetry-venv/bin/python3

yrro avatar Sep 17 '21 12:09 yrro

Should be fixed via https://github.com/python-poetry/poetry/pull/4507

finswimmer avatar Sep 20 '21 18:09 finswimmer

Thanks!

christopherpickering avatar Sep 21 '21 06:09 christopherpickering

(WSL) i seem to still get this issue after installing today via

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

reinstalling python3.9 does not seem to resolve

/usr/bin/env: β€˜python\r’: No such file or directory

reinstalling poetry receives

bash: /usr/bin/python: No such file or directory

as i uninstalled python-is-python3, aliases and that would have removed the alternatives aliases

edit:

this was fixed via https://lifesaver.codes/answer/include-installation-instructions-for-python3-721

where this is suggested:

One of:

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

however

poetry run still fails

edit again

source $HOME/.poetry/env python3

solves this, leaving this here for others as this was google top result for me

ooliver1 avatar Apr 09 '22 14:04 ooliver1

Still present on Ubuntu 22.04

poetry --version
Poetry version 1.1.13
poetry debug

Poetry
Version: 1.1.13
Python:  3.10.4

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.10/subprocess.py:1842 in _execute_child
      1838β”‚                     else:
      1839β”‚                         err_filename = orig_executable
      1840β”‚                     if errno_num != 0:
      1841β”‚                         err_msg = os.strerror(errno_num)
    β†’ 1842β”‚                     raise child_exception_type(errno_num, err_msg, err_filename)
      1843β”‚                 raise child_exception_type(err_msg)
      1844β”‚ 
      1845β”‚ 
      1846β”‚         def _handle_exitstatus(self, sts,

Sispheor avatar May 30 '22 13:05 Sispheor

I still face it. Shouldn't be closed!

matheushent avatar Jun 06 '22 18:06 matheushent