-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to Exit Poetry Virtual Environment #2792
Comments
Just use |
@beeb Thank you for your suggestion, but I don't want to close the shell. I often have to switch back and forth between multiple activities and projects and I want to use one window. In fact, I don't need a new shell to be spawned every time I want to use the environment. In short, I would like the feel of I realize there is a lot of development activity ongoing with |
I pretty much achieve exactly the behavior you are describing by using |
@beeb I see, okay. Is there a reason why |
Are you actually using poetry with your IDE? In VSCode it doesn't open a pop-up or anything. (base) ➜ my_folder git:(develop) ✗ poetry shell
Spawning shell within /Users/beeb/my_folder/.venv
(base) ➜ my_folder git:(develop) ✗ . /Users/beeb/my_folder/.venv/bin/activate
(.venv) (base) ➜ my_folder git:(develop) ✗ which python
/Users/beeb/my_folder/.venv/bin/python I'm afraid I cannot answer your question on the reason behind spawning a new shell since I'm not involved in the development. Just another user trying to help |
@adam-grant-hendry If you are not already familiar with it, I would recommend reading up on how virtual environments work. You will find that they depend on some trickery using shell environment variables ( It is important to note that $ python -c "import os; os.environ['TEST']='1'; print(os.environ['TEST'])"
1
$ echo -n $TEST
$ There are a few workaround that can approximate this (windows registry hacks etc.), but these typically creates more problems than they solve. This means that we cannot activate a virtual environment in the parent shell using a python cli application. Hence why, we spawn a sub shell with the virtual environment activated. You will note that we use As for your comment regarding issues with IDEs, I am not sure I follow. Typically with IDEs, you will configure the virtual environment path and not use Regarding "exiting" the shell, I am afraid I have to agree with @beeb that the typical case is to use |
@beeb Yes, you are right. VSCode doesn't open a new CLI window when a new shell is spawned. I have been using it in VSCode, but I thought @abn Thank you very much for this insight into virtual environments (I will read up on this) and the inner workings of "Using VSCode, I can set
in user settings. Now, upon opening VSCode, the However, after running
" How do I deactivate the virtual environment within |
@adam-grant-hendry I think you are conflating a few different mechanisms here. With respect to poetry commands, most are run within the project's virtual environment. So even if you do not have The specific message you are referring to could be improved, I suppose, as it is merely indicating the current/default environment for the project not necessarily detecting if it is active currently in the parent shell. poetry/poetry/console/commands/env/list.py Lines 13 to 29 in bce954a
|
@abn Ah! Yes I see, this message was absolutely confusing me. So if I |
You can do that or activate the environment prior to running poetry commands. If a virtual environment is already active when you execute poetry, then Poetry will use that. What works of my personal use is the |
@abn and @finswimmer +1 for as adding this to |
I get error when creating my own virtual environment with |
#2417 resolves gap in documentation. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Related to #1057. Please add
poetry exit
or equivalent to exit virtual environment.The text was updated successfully, but these errors were encountered: