poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Discovered shell 'bash' doesn't have an activator in virtual environment

Open siddjain opened this issue 9 months ago • 4 comments

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.

siddjain avatar Jun 10 '25 01:06 siddjain

I'm also having this issue

EricTheMagician avatar Jun 19 '25 22:06 EricTheMagician

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.

radoering avatar Jun 22 '25 15:06 radoering

I have this problem as well, running on MacOS 15.5 with python 13.3

rpgoldman avatar Jul 11 '25 18:07 rpgoldman

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.

NicolasRichel avatar Jul 15 '25 21:07 NicolasRichel