How to delete virtual env? #3690
-
How do I delete a virtual env? I tried just deleting the file but poetry stopped working after that. |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 3 replies
-
The latest preview version (which can be installed with If you want to see where the virtualenv is stored, there are various ways to print it out. |
Beta Was this translation helpful? Give feedback.
-
On macOS, envs are located here |
Beta Was this translation helpful? Give feedback.
-
On Linux, the easiest way to find the virtualenv is to pop into a subshell and run
|
Beta Was this translation helpful? Give feedback.
-
I feel like this should be easier. Maybe something like |
Beta Was this translation helpful? Give feedback.
-
@arnegroskurth the As pointed out above you can also do |
Beta Was this translation helpful? Give feedback.
-
@abn Sure but that is more complicated and requires the user to know about the So I feel like there should be something to just level the playing-field without me having to think about venvs again. |
Beta Was this translation helpful? Give feedback.
-
Sounds to me more like a deficiency in the documentation and/or onboarding guide for a new user to Poetry. That is definitely an area that we are interested in improving on. At this time, I do not think we want to encourage the addition of multiple commands to do the same task. And, personally, adding something like |
Beta Was this translation helpful? Give feedback.
-
@abn I just feel like that the benefit of using poetry over venv+pip is for the user to not have to care about two separate tools for dependency-management and project-isolation anymore. And because I can create and update the environment with top-level poetry commands, I feel like that I should also be able to remove the environment with a top-level command that is much more discoverable ( |
Beta Was this translation helpful? Give feedback.
-
That definitely is one of the advantages of using poetry. Although, it is important to note that explicit creation of an environment relies on We appreciate your feedback on this. However, for this matter I do not see a reason to change the current behaviour at this time. |
Beta Was this translation helpful? Give feedback.
-
Please note that the suggested command can be quite dangerous if accidentally run in a directory not handled by poetry. |
Beta Was this translation helpful? Give feedback.
-
This worked for me:
Running |
Beta Was this translation helpful? Give feedback.
-
you can actually just run |
Beta Was this translation helpful? Give feedback.
-
addendum: just note the so, if your default path the lookup is here: execute code using the |
Beta Was this translation helpful? Give feedback.
-
If you want to remove all environments for a given project: |
Beta Was this translation helpful? Give feedback.
-
One thing I'm still unclear on is how to remove old environments. Imagine that in some python project the python-version has been upgraded to from python 3.X to 3.Y I now want to remove the old one(s) safely and have no earthly idea which ones I should remove. My go to solution has been to periodically remove everything in the |
Beta Was this translation helpful? Give feedback.
-
It would be good to have a way to remove env for projects that you have already deleted from the file system. Maybe just a |
Beta Was this translation helpful? Give feedback.
@arnegroskurth the
poetry env remove <python>
command does this.As pointed out above you can also do
rm -rf `poetry env info -p`
to remoe the virtual env directory depending on what you need to do.