Discovered shell 'bash' doesn't have an activator in virtual environment
Description
I was using Poetry 1.x and it was working fine. I used to run poetry shell to activate the poetry virtual environment. Then I upgraded to Poetry 2.x. Now when I run poetry env activate I get this:
$ poetry env activate
The currently activated Python version 3.8.20 is not supported by the project (^3.10).
Trying to find and use a compatible version.
Using python3.10 (3.10.12)
Discovered shell 'bash' doesn't have an activator in virtual environment
Workarounds
.
Poetry Installation Method
pipx
Operating System
Ubuntu 24
Poetry Version
Poetry (version 2.1.3)
Poetry Configuration
$ poetry config --list
cache-dir = "/home/xxx/.cache/pypoetry"
data-dir = "/home/xxx/.local/share/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python" # /home/xxx/.local/share/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/xxx/.cache/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false
Python Sysconfig
sysconfig.log
Paste the output of 'python -m sysconfig', over this line.
Example pyproject.toml
Poetry Runtime Logs
poetry-runtime.log
Paste the output of 'poetry -vvv <command>', over this line.
I'm also having this issue
Seems like this happens only if Poetry has to "find and use a compatible version" and if virtualenvs.in-project is false.
This line seems to return the wrong env:
https://github.com/python-poetry/poetry/blob/01955bbf46176a701da719c970ae8084951efa8a/src/poetry/console/commands/env/activate.py#L28
Maybe, we can just use self.env instead.
I have this problem as well, running on MacOS 15.5 with python 13.3
I ran into the same issue on Ubuntu 24.04 with poetry 2.1.3 and was able to get rid of it by running:
$ poetry env use 3.13
Then:
$ poetry env activate
Hope this helps.