Search all available Python Virtual environments under a specific given directory location.
python 3.7+
- No extra packages required, all built-in python modules are used
- os
- time
- timeit
- multiprocessing
- python detect_venv.py
[x] Inputs:
-
Enter the number of parallel searches you want to do
- Example, Search inside, Desktop, Documents,and Music Folders at the same time (used multiprocessing pool)
-
Enter the path to the folder you want to search inside [suppose, venv is a vritualenvironment of Python, and is under Desktop, if you put location to Dekstop, my script will detect the virtualenvironment]
[x] Outputs:
- It'll output series of all virtual-environments found
- A text file is generated, named in the format test_op_{dir_name_searching}.txt
- For example, If you search in Desktop, you'll get a text file generated as test_op_Desktop.txt.
- The location of the generated text file is same as the directory from where you are running the detect_venv.py
I recently thought of copying all my python related coding projects into another drive, but I see almost 3 GB consists of only virtualenvs! So, I thought, if I can filter the directory to the virtualenvs, I can exclude them from being copied and copy only the Python project folders. It basically, searches for a list of pattern of files and folder inside a directory to consider it as a virtualenvironment
Script performs using the following logic:
-
search_directory is a virtualenv
-
Note down search directory in the respective text file
I'll add the logic for searching virtualenvs ob linux environments too, very soon, stay updated.
New:
- Added feature to detect venvs also in linux based operating systems.
- Added script (delete_venvs.py) to selectively delete
venv
detected using detect_venv.py from the*.txt
file generated. (As mentioned in output format.)
- Added functionality in delete_venvs.py, to pass
-y
in command line args to automatically delete all virtualenvs.