poetry shell failing to set up my .venv local environment
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).
- OS version and name: Ubuntu 22.04 (WSL2)
- Poetry version: 1.1.13
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/epomatti/68b318e2cda239dfda5f317f170b0243
Issue
My project is set up to use in-project virtual environments. My poetry.toml
:
[virtualenvs]
in-project = true
I make sure that my envs are empty:
$ poetry env list
# envs are empty
I install the dependencies, and it creates the .venv
directory in the root of my project. The command appears to complete successfully, but there is a problem.
$ poetry install

The problem is that virtual env shell did not initiate. It doesn’t have the (.venv)
prefix in my terminal.
If I try poetry shell
I get the following warning:
$ poetry shell
The virtual environment found in /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv seems to be broken.
It appears to be broken. But why didn’t it tell me so in the previous command?
Now if I exit and try again, then it shows what it seems to be the root cause:
$ exit
exit
pomatti@DESKTOP-DP18TG3:~/pjs/azure/azure-multiregion-aks-cluster/microservices/utils$ poetry shell
The virtual environment found in /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv seems to be broken.
Recreating virtualenv aksmr-utils in /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv
Spawning shell within /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv
pomatti@DESKTOP-DP18TG3:~/pjs/azure/azure-multiregion-aks-cluster/microservices/utils$ . /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv/bin/activate
bash: /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv/bin/activate: No such file or directory
It is trying to to call .venv/bin/activate
which doesn’t exist, because it has been created as .venv/local/bin/activate
. Why?
Now to add to this whole thing, even if I manually activate it with source .venv/local/bin/activate
, VS Code is not recognizing the environment, and I also can’t add new packages.
$ poetry add azure.identity
The virtual environment found in /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv seems to be broken.
Recreating virtualenv aksmr-utils in /home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv
FileNotFoundError
[Errno 2] No such file or directory: '/home/pomatti/pjs/azure/azure-multiregion-aks-cluster/microservices/utils/.venv/local/bin/python3'
at ~/.poetry/lib/poetry/_vendor/py3.10/virtualenv/discovery/builtin.py:91 in propose_interpreters
87│
88│ # 1. if it's a path and exists
89│ if spec.path is not None:
90│ try:
→ 91│ os.lstat(spec.path) # Windows Store Python does not work with os.path.exists, but does for os.lstat
92│ except OSError:
93│ if spec.is_abs:
94│ raise
95│ else:
What is going on?
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Thanks for closing the loop (again) @epomatti. Much appreciated. 💜
Odd. Thanks for closing the loop @epomatti .