Loading configuration file /Users/ericdufresne/Library/Preferences/pypoetry/config.toml
Loading configuration file /Users/ericdufresne/Library/Preferences/pypoetry/auth.toml
Stack trace:
17 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cleo/application.py:329 in run
328│ try:
→ 329│ exit_code = self._run(io)
330│ except Exception as e:
331│ if not self._catch_exceptions:
16 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/console/application.py:185 in _run
183│ self._load_plugins(io)
→ 185│ exit_code: int = super()._run(io)
186│ return exit_code
15 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cleo/application.py:423 in _run
421│ io.input.set_stream(stream)
→ 423│ exit_code = self._run_command(command, io)
424│ self._running_command = None
14 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cleo/application.py:465 in _run_command
464│ if error is not None:
→ 465│ raise error
467│ return event.exit_code
13 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cleo/application.py:446 in _run_command
445│ try:
→ 446│ self._event_dispatcher.dispatch(event, COMMAND)
448│ if event.command_should_run():
12 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cleo/events/event_dispatcher.py:23 in dispatch
22│ if listeners:
→ 23│ self._do_dispatch(listeners, event_name, event)
25│ return event
11 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/cleo/events/event_dispatcher.py:84 in _do_dispatch
82│ break
→ 84│ listener(event, event_name, self)
86│ def _sort_listeners(self, event_name: str) -> None:
10 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/console/application.py:294 in configure_env
293│ env_manager = EnvManager(poetry)
→ 294│ env = env_manager.create_venv(io)
296│ if env.is_venv() and io.is_verbose():
9 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:833 in create_venv
832│ cwd = self._poetry.file.parent
→ 833│ env = self.get(reload=True)
835│ if not env.is_sane():
8 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:711 in get
709│ return self.get_system_env()
→ 711│ return VirtualEnv(venv)
713│ if env_prefix is not None:
7 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:1652 in __init__
1650│ # from inside the virtualenv.
1651│ if base is None:
→ 1652│ output = self.run_python_script(GET_BASE_PREFIX)
1653│ assert isinstance(output, str)
1654│ self._base = Path(output.strip())
6 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:1438 in run_python_script
1436│
1437│ def run_python_script(self, content: str, **kwargs: Any) -> int | str:
→ 1438│ return self.run(self._executable, "-W", "ignore", "-", input_=content, **kwargs)
1439│
1440│ def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
5 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:1430 in run
1428│ def run(self, bin: str, *args: str, **kwargs: Any) -> str | int:
1429│ cmd = self.get_command_from_bin(bin) + list(args)
→ 1430│ return self._run(cmd, **kwargs)
1431│
1432│ def run_pip(self, *args: str, **kwargs: Any) -> int | str:
4 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:1712 in _run
1710│ def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
1711│ kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
→ 1712│ return super()._run(cmd, **kwargs)
1713│
1714│ def get_temp_environ(
3 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/poetry/utils/env.py:1459 in _run
1457│
1458│ if input_:
→ 1459│ output = subprocess.run(
1460│ command,
1461│ stdout=subprocess.PIPE,
2 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:503 in run
501│ kwargs['stderr'] = PIPE
→ 503│ with Popen(*popenargs, **kwargs) as process:
504│ try:
505│ stdout, stderr = process.communicate(input, timeout=timeout)
1 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:971 in __init__
969│ encoding=encoding, errors=errors)
→ 971│ self._execute_child(args, executable, preexec_fn, close_fds,
972│ pass_fds, cwd, env,
973│ startupinfo, creationflags, shell,
FileNotFoundError
[Errno 2] No such file or directory: 'python'
at /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/subprocess.py:1847 in _execute_child
1843│ else:
1844│ err_filename = orig_executable
1845│ if errno_num != 0:
1846│ err_msg = os.strerror(errno_num)
→ 1847│ raise child_exception_type(errno_num, err_msg, err_filename)
1848│ raise child_exception_type(err_msg)
1849│
1850│
1851│ def _handle_exitstatus(self, sts,
Extra Info
Python location /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
Poetry location /Library/Frameworks/Python.framework/Versions/3.10/bin/poetry
Issue
Hello. I am trying to use Poetry for mac with Python 3.10. It was working before but I re-installed both Python and poetry and I can't seem to get it to work. I can run commands like poetry --version
but commands such as poetry install
poetry lock
poetry show
all faill with [Errno 2] No such file or directory: 'python'
and the above stack trace on debug mode.
I have tried installing Poetry both with curl -sSL https://install.python-poetry.org | python3 -
as well as the manual way with pip3 install poetry
. My Python is installed via the regular Python.org .pkg
installer for MacOS but I had it installed with homebrew before which also suffered from the same issue.
Thank you in advance for the help!
It looks like you have a broken virtual environment -- I'd suggest cleaning up with rm -rf .venv && poetry env remove --all
. I suspect that the virtual env looks valid but has a broken symlink for the Python binary, based on the output (we're failing in env.py
, during commands which rely on the environment existing and need to introspect it).
danitZeekit, Axel-Gohier, nv-ncurry, matiskay, tomasyany, andrii0yerko, nielsyh, PabloRuizCuevas, hokahokabob, adamdabbracci, and 20 more reacted with thumbs up emoji
manoadamro, jkl1337, vlad0337187, JulianoLagana, bwahacker, JustinShuttleworth, tsonev7, hansvdam, ruiheesi, mohdrasbi, and 9 more reacted with thumbs down emoji
bjoluc, joaosilvanogueira, ragyabraham, EliahKagan, StephanSchmiedmayer, rodrigogiraoserrao, samsammurphy, danitZeekit, csangonzo, vaibhavhrt, and 4 more reacted with heart emoji
goodjack, AbhilashPal, and tenlisboa reacted with rocket emoji
All reactions
Where is .venv
supposed to be located? It didn't exist in my project's directory and both of the commands:
poetry env list
poetry env remove --all
fail with the same command
.venv
may exist if you set poetry config virtualenvs.in-project true
. I was trying to provide a one-liner, but if poetry env remove
is broken, you can instead do rm -rf $(poetry config virtualenvs.path)/*
to blow away all of your Poetry environments.
Edit: Please ensure poetry config virtualenvs.path
does in fact return a valid path before trying to use the rm -rf
command. If it's empty you might end up with an attempt to remove your entire root partition.
vladimirshkoda, hom-bahrani, zabop, wojtekwalczak, lukasz-segin, ivenpoker, wrwrwr, FrancisZhuang, fhuadeen, mateusz91t, and 17 more reacted with thumbs up emoji
dbersan, MDeadman, leetdavid, raminqaf, fmacedoo, guatavita, shubhamg931, goodjack, debymf, and james-channel reacted with thumbs down emoji
GyurkanM, sergei-rastrigin, ogola89, fmelihh, and karyna-zuyeva reacted with laugh emoji
edufresne, acpn, novemberkilo, johnthagen, alikhan126, viniciuspiloto, JinkunSun, ogola89, and ugolbck reacted with hooray emoji
slonokot, caroAM22, amucunguzi, smorton2, delpieron-hash, and tenlisboa reacted with heart emoji
All reactions
That did the trick! Had to go in manually and delete the virtualenvs in the default virtualenv directory with your command . I then was able to set poetry config virtualenvs.in-project true
and create my virtualenvs on the project level.
Thanks for your help!
Poetry tries using Python2 (usr/local/bin/python) instead of the provided distribution during install
#6940
.venv
may exist if you set poetry config virtualenvs.in-project true
. I was trying to provide a one-liner, but if poetry env remove
is broken, you can instead do rm -rf $(poetry config virtualenvs.path)/*
to blow away all of your Poetry environments.
This command deleted my teammate's entire Ubuntu partition 😄
Buillaume, johnthagen, PabloEmidio, lucasnobre212, binhotvn, Vuizur, flavioneri, sunsear, roman-kh, geekkun, and 65 more reacted with laugh emoji
mstniy, Martins6, ShinnosukeUesaka, chachra, Keped, and shubhamg931 reacted with confused emoji
All reactions
ggoncalves-encora, wuhomie, approximatenumber, pstrasser, JamesAlvesISH, abhishekrana, ShanWeera, NaitoKenzo, lcarlier, gudbrandtandberg, and 22 more reacted with thumbs up emoji
csangonzo, OmarHory, ozsaygin, and reach-will reacted with laugh emoji
sourceful-taylor, forgedis, peidrao, FredericLespez, and AndresGL01 reacted with hooray emoji
All reactions
Seems like some part of poetry is trying to run python
instead of referring to sys.executable
...
Yup, in poetry.utils.env.GenericEnv
, find_executables
is grubbing around for hard coded executable names instead of using sys.executable
.
(Seen here with Poetry 1.3.2)
ON MAC what worked was reinstalling Poetry
curl -sSL https://install.python-poetry.org | python3 -
or, if you use homebrew:
brew install pipx
pipx install poetry
For me, the issue was that I set prefer-active-python
to true meanwhile, i only have the python3
command active so python
command would not work. Setting this to false or linking python
command to python3
will do the trick. This is the idea also of the command sudo apt install python-is-python3
suggested up.
We did something like this (only we set POETRY_HOME to /etc/poetry). For some reason python was in a venv subdirectory:
export POETRY_HOME=/usr
curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
export PATH=$PATH:$POETRY_HOME/venv/bin
Poetry install then worked and found Python.
$POETRY_HOME/bin/poetry install
I had this issue recently but only for one repository. I tried the solutions above but they didn't work for me. It turned out to be a caching issue and I ended up having to:
Delete the entry in /Users/<user>/Library/Caches/pypoetry/virtualenvs/envs.toml
for the repository I was working on
Delete any previous virtualenvs for the repository in /Users/<user>/Library/Caches/pypoetry/virtualenvs
I worked out it was a caching issue by finding I could poetry install
my package if I changed its name in pyproject.toml
.
.venv
may exist if you set poetry config virtualenvs.in-project true
. I was trying to provide a one-liner, but if poetry env remove
is broken, you can instead do rm -rf $(poetry config virtualenvs.path)/*
to blow away all of your Poetry environments.
I have removed all env as you recommended - no envs left, not in the Library/Caches and not in my project (I set config virtualenvs.in-project true), however the problem remains. Where can I fix this symlink to 'python'? Thanks for your help!
After migrating my mac to ARM I fixed it with a symbolic link. Setting an alias in zsh was not enough.
ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python
After migrating my mac to ARM I fixed it with a symbolic link. Setting an alias in zsh was not enough. ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python
This is the only thing that worked for me.