How do I go about removing all these virtual environments? I don't know where the directories are
            Asked
            
        
        
            Active
            
        
            Viewed 4.8k times
        
    39
            
            
         
    
    
        ChrisGPT was on strike
        
- 127,765
- 105
- 273
- 257
 
    
    
        alois
        
- 513
- 1
- 4
- 6
- 
                    Have you checked that topic ? https://stackoverflow.com/questions/11005457/how-do-i-remove-delete-a-virtualenv – Henry Mont Dec 01 '20 at 19:57
- 
                    Yes. I don't know where these virtualenv's directories are. All I know about them is what they are called. – alois Dec 01 '20 at 20:05
- 
                    Are you on windows or linux ? – Henry Mont Dec 01 '20 at 20:16
- 
                    1Neither, I'm on mac os. – alois Dec 01 '20 at 20:22
- 
                    4[Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied and offer poor usability. Instead, paste the code as text directly into your question. If you select it and click the `{}` button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code. – ChrisGPT was on strike Dec 01 '20 at 20:43
3 Answers
40
            
            
        Assuming that list came from running pyenv virtualenvs, you should be able to run
pyenv uninstall 3.8.2/envs/greenhouse
to remove the 3.8.2/envs/greenhouse environment.
The environments themselves should be subdirectories of whatever pyenv root returns when you run it. Try doing cd $(pyenv root) and then looking in the versions/ and versions/{version}/envs/ subdirectories.
 
    
    
        ChrisGPT was on strike
        
- 127,765
- 105
- 273
- 257
20
            
            
        You can also use:
pyenv virtualenv-delete <venv-name> - Delete Virtual Environment
 
    
    
        lloyd-dotmodus
        
- 211
- 2
- 2
2
            
            
        Adding to Chris's answer, you might also need to delete the local .python-version:
$ pyenv uninstall 3.8.12/envs/test_venv 
pyenv-virtualenv: remove /home/user1/.pyenv/versions/3.8.12/envs/test_venv? (y/N) y
$ python -V
pyenv: version 'test_venv' is not installed (set by /home/user1/.python-version)
$ rm .python-version 
rm: remove regular file '.python-version'? y
$ python -V
Python 3.8.12
 
    
    
        natskvi
        
- 125
- 2
- 9
