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.

[Errno 2] No such file or directory: 'python' on almost all poetry commands

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.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

Running into an issue in which I cannot run many Poetry commands in my project (e.g. poetry update, poetry shell, etc.). Tried in both zsh and bash. I get the error [Errno 2] No such file or directory: 'python'. I initially set up this project with the default settings, but I’ve since changed virtualenvs.create and virtualenvs.in-project to be true. Since this change I get these errors. Deleting the .venv/ directory in the project directory does not fix the issue.

Here’s my current ~/.config/pypoetry/config.toml

[virtualenvs]
create = true
in-project = true

Output of poetry config --list (if that helps):

cache-dir = "/home/david/snap/alacritty/common/.cache/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/david/snap/alacritty/common/.cache/pypoetry/virtualenvs

I’ve found that if I completely comment out my ~/.config/pypoetry/config.toml file, I am then able to run poetry shell, which it appears to be installing in the default cache-dir directory. However, I would like to have my virtualenvs in the individual projects.

Output of poetry shell -vvv:

  Stack trace:

  14  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py:131 in run
       129β”‚             parsed_args = resolved_command.args
       130β”‚
     β†’ 131β”‚             status_code = command.handle(parsed_args, io)
       132β”‚         except KeyboardInterrupt:
       133β”‚             status_code = 1

  13  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:120 in handle
       118β”‚     def handle(self, args, io):  # type: (Args, IO) -> int
       119β”‚         try:
     β†’ 120β”‚             status_code = self._do_handle(args, io)
       121β”‚         except KeyboardInterrupt:
       122β”‚             if io.is_debug():

  12  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:163 in _do_handle
       161β”‚         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
       162β”‚             event = PreHandleEvent(args, io, self)
     β†’ 163β”‚             self._dispatcher.dispatch(PRE_HANDLE, event)
       164β”‚
       165β”‚             if event.is_handled():

  11  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:22 in dispatch
        20β”‚
        21β”‚         if listeners:
     β†’  22β”‚             self._do_dispatch(listeners, event_name, event)
        23β”‚
        24β”‚         return event

  10  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
        87β”‚                 break
        88β”‚
     β†’  89β”‚             listener(event, event_name, self)
        90β”‚
        91β”‚     def _sort_listeners(self, event_name):  # type: (str) -> None

   9  ~/.poetry/lib/poetry/console/config/application_config.py:119 in set_env
       117β”‚
       118β”‚         env_manager = EnvManager(poetry)
     β†’ 119β”‚         env = env_manager.create_venv(io)
       120β”‚
       121β”‚         if env.is_venv() and io.is_verbose():

   8  ~/.poetry/lib/poetry/utils/env.py:659 in create_venv
        657β”‚
        658β”‚         cwd = self._poetry.file.parent
     β†’  659β”‚         env = self.get(reload=True)
        660β”‚
        661β”‚         if not env.is_sane():

   7  ~/.poetry/lib/poetry/utils/env.py:531 in get
        529β”‚             base_prefix = self.get_base_prefix()
        530β”‚
     β†’  531β”‚         return VirtualEnv(prefix, base_prefix)
        532β”‚
        533β”‚     def list(self, name=None):  # type: (Optional[str]) -> List[VirtualEnv]

   6  ~/.poetry/lib/poetry/utils/env.py:1361 in __init__
       1359β”‚         if base is None:
       1360β”‚             self._base = Path(
     β†’ 1361β”‚                 self.run(self._executable, "-", input_=GET_BASE_PREFIX).strip()
       1362β”‚             )
       1363β”‚

   5  ~/.poetry/lib/poetry/utils/env.py:1140 in run
       1138β”‚         bin = self._bin(bin)
       1139β”‚         cmd = [bin] + list(args)
     β†’ 1140β”‚         return self._run(cmd, **kwargs)
       1141β”‚
       1142β”‚     def run_python(self, *args, **kwargs):

   4  ~/.poetry/lib/poetry/utils/env.py:1440 in _run
       1438β”‚     def _run(self, cmd, **kwargs):
       1439β”‚         kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
     β†’ 1440β”‚         return super(VirtualEnv, self)._run(cmd, **kwargs)
       1441β”‚
       1442β”‚     def get_temp_environ(

   3  ~/.poetry/lib/poetry/utils/env.py:1165 in _run
       1163β”‚
       1164β”‚             if input_:
     β†’ 1165β”‚                 output = subprocess.run(
       1166β”‚                     cmd,
       1167β”‚                     stdout=subprocess.PIPE,

   2  ~/.poetry/lib/poetry/utils/_compat.py:200 in run
       198β”‚             kwargs["stdin"] = PIPE
       199β”‚
     β†’ 200β”‚         process = Popen(*popenargs, **kwargs)
       201β”‚         try:
       202β”‚             process.__enter__()  # No-Op really... illustrate "with in 2.4"

   1  /usr/lib/python3.8/subprocess.py:858 in __init__
        856β”‚                             encoding=encoding, errors=errors)
        857β”‚
     β†’  858β”‚             self._execute_child(args, executable, preexec_fn, close_fds,
        859β”‚                                 pass_fds, cwd, env,
        860β”‚                                 startupinfo, creationflags, shell,

  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,

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
Teemucommented, Jul 12, 2022

Removing the cache helped for me:

rm -rf ~/Library/Caches/pypoetry
3reactions
haoxinscommented, Apr 21, 2022
curl -sSL https://install.python-poetry.org | python3 -

Installing the latest version solved this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running poetry fails with /usr/bin/env: 'python': No such file or ...
poetry is dependent on whatever python is and doesn't attempt to use a specific version of python unless otherwise specified.
Read more >
[Errno 2] No such file or directory | by Aurora - Medium
Solution. To uninstall Poetry without the above error: Try executing this β€” curl -sSL https://raw.githubusercontent.com/sdispater/poetry/Β ...
Read more >
poetry install [errno 2] no such file or directory: 'python'
The error occurs on the third line of the train method but you catch that one. However, in the catch you try the...
Read more >
Python Virtual Environments tutorial using ... - SerpApi
Everything is almost the same except you don't need to find a poetry cache folder via command line to find a path to...
Read more >
How to Publish an Open-Source Python Package to PyPI
The inner src/reader/ directory contains all your source code: ... Python Package to PyPI 1 The Real Python Podcast – Episode #110 2...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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