The logic for detecting Python virtual environment folders needs to be improved. Your implementation assumes that the folder would simply be named either venv
or env
, but that is not always the case. Python places no restrictions on the folder name, so most documentations/guides on the internet suggest using a custom name, which means that a Python virtual environment folder can actually be named anything at all, e.g. alxcheck_venv
or _python_bin
. I name mine .venv
for instance, so that it stays at the top of the list in a directory listing, with the added advantage of being hidden and ignored by most apps in UNIX.
However, regardless of what the folder is named, it always has a ./pyvenv.cfg
file in it (see attached screenshot), so perhaps have your script look for that file instead, or a similar artefact that applies to all virtual environment folders.
![image](https://private-user-images.githubusercontent.com/95923018/283986796-bb1cac3e-aaae-4661-b8a6-4dda3e56192a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM1NTQ3MjgsIm5iZiI6MTcyMzU1NDQyOCwicGF0aCI6Ii85NTkyMzAxOC8yODM5ODY3OTYtYmIxY2FjM2UtYWFhZS00NjYxLWI4YTYtNGRkYTNlNTYxOTJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODEzVDEzMDcwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM0MzI2NjVjMWY1MWM5YWVmNDRmNjAwMmY3OGZhYTAxZDBkMjdlNzFjNDFlMWRmODc1YzUwMzU2OWM1OGEzZmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Xikl9qilaGRItRPEi3BTFQPi4pBT5C8_JmumVADVA9M)
Source: official documentation