Today I Learned
Search…
Finding all Python Virtual Environments in your system
So if you work with Python all day, you already know about Virtual Environments. The only problem with me πŸ˜… is that I end up creating a lot of them when using and making my side-projects. We know that there is a activate script that can be used for this purpose.
shut up & give me answer
Ok

Using find

1
find /home -name "*activate"
Copied!
This will list out all activate scripts in your home directory (should work fine). Only problem, it is slow.
Sample Ouput
1
/home/bhupesh/Desktop/testFind/bin/activate
2
/home/bhupesh/Desktop/bits/bin/activate
3
/home/bhupesh/Desktop/cc-new/bin/activate
4
/home/bhupesh/Desktop/test-audio/bin/activate
5
/home/bhupesh/Desktop/comp-code/bin/activate
6
/home/bhupesh/Desktop/req-blog/bin/activate
7
/home/bhupesh/Desktop/py-cli/bin/activate
8
/home/bhupesh/Desktop/sian-env/bin/activate
9
/home/bhupesh/Desktop/ques/bin/activate
10
/home/bhupesh/Documents/api/bin/activate
11
/home/bhupesh/Documents/defe-venv/bin/activate
12
/home/bhupesh/Documents/bot-tutorial/bin/activate
13
/home/bhupesh/Documents/cc/bin/activate
14
/home/bhupesh/Documents/test-package/bin/activate
15
/home/bhupesh/Documents/qt-lear/bin/activate
16
/home/bhupesh/Documents/csv-voil/bin/activate
17
/home/bhupesh/Documents/bottest/bin/activate
18
/home/bhupesh/Documents/new-tutorialdb/bin/activate
19
/home/bhupesh/Documents/cc2/bin/activate
20
/home/bhupesh/Documents/plag/bin/activate
21
find /home -name "*activate" 2.57s user 4.14s system 7% cpu 1:31.72 total
Copied!

Using locate

1
locate -b '\activate' | grep "/home"
Copied!
Grep your home directory for all activate scripts.
Sample Output
1
/home/bhupesh/Desktop/bits/bin/activate
2
/home/bhupesh/Desktop/cc-new/bin/activate
3
/home/bhupesh/Desktop/comp-code/bin/activate
4
/home/bhupesh/Desktop/py-cli/bin/activate
5
/home/bhupesh/Desktop/ques/bin/activate
6
/home/bhupesh/Desktop/req-blog/bin/activate
7
/home/bhupesh/Desktop/sian-env/bin/activate
8
/home/bhupesh/Desktop/test-audio/bin/activate
9
/home/bhupesh/Desktop/testFind/bin/activate
10
/home/bhupesh/Documents/api/bin/activate
11
/home/bhupesh/Documents/bot-tutorial/bin/activate
12
/home/bhupesh/Documents/bottest/bin/activate
13
/home/bhupesh/Documents/cc/bin/activate
14
/home/bhupesh/Documents/cc2/bin/activate
15
/home/bhupesh/Documents/csv-voil/bin/activate
16
/home/bhupesh/Documents/defe-venv/bin/activate
17
/home/bhupesh/Documents/new-tutorialdb/bin/activate
18
/home/bhupesh/Documents/plag/bin/activate
19
/home/bhupesh/Documents/qt-lear/bin/activate
20
/home/bhupesh/Documents/test-package/bin/activate
21
locate -b '\activate' 0.45s user 0.02s system 99% cpu 0.476 total
22
grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} "/home" 0.00s user 0.00s system 0% cpu 0.472 total
Copied!
Now you can just do source <path>.
Copy link
Edit on GitHub