[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 (
-vvvoption).
- OS version and name: Ubuntu 20.04
- Poetry version: 1.1.10
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/dfontenot/bdaa7940af0a9bc72c41e91500072880#file-pyproject-toml
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:
- Created 2 years ago
- Reactions:1
- Comments:14 (3 by maintainers)
Top Related StackOverflow Question
Removing the cache helped for me:
Installing the latest version solved this issue.