Skip to content

Instantly share code, notes, and snippets.

@talwai
Created July 28, 2014 03:36
Show Gist options
  • Save talwai/3830aaca7bde73743218 to your computer and use it in GitHub Desktop.
Save talwai/3830aaca7bde73743218 to your computer and use it in GitHub Desktop.
List Python versions and packages installed in all virtualenvs under a directory
#!/usr/bin/env bash
: <<'END'
Sample Run: ./list_venvs.sh /Users/talwai/
Sample Output:
-----------------------
DIRECTORY: /Users/talwai/qorpus_env
PYTHON_VERSION: 3.3.2
PACKAGES:
PyYAML==3.11
amqp==1.4.5
anyjson==0.3.3
beautifulsoup4==4.3.2
billiard==3.3.0.17
celery==3.1.11
kombu==3.0.16
lxml==3.3.5
pymongo==2.7.1
python-docx==0.5.1
pytz==2014.2
redis==2.9.1
selenium==2.42.0
-----------------------
DIRECTORY: /Users/talwai/rapcountr_api_env
PYTHON_VERSION: 3.3.2
PACKAGES:
Django==1.6.5
django-cors-headers==0.12
pymongo==2.7.1
-----------------------
...etc
END
DEFAULT_DIR=$(pwd)
WORKING_DIR=${1:-$DEFAULT_DIR}
FILES=`find $WORKING_DIR -name .Python`
printf '%s\n' '-----------------------'
for f in $FILES
do
cd `dirname $f`
printf "DIRECTORY:\t$(pwd) \n"
source bin/activate
printf "PYTHON_VERSION: \t \
$(python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))') \n"
printf "PACKAGES: \n$(pip freeze) \n"
deactivate
cd - > /dev/null
printf '%s\n' '-----------------------'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment