Skip to content

Instantly share code, notes, and snippets.

@kittolau
Last active October 2, 2015 17:30
Show Gist options
  • Save kittolau/d474d6806acdbb34a0dc to your computer and use it in GitHub Desktop.
Save kittolau/d474d6806acdbb34a0dc to your computer and use it in GitHub Desktop.
virtualenv cheat sheet
#To solve the InsecurePlatformWarning
#==========================================
#for ubuntu
sudo apt-get install libffi-dev libssl-dev
pip install pyopenssl ndg-httpsclient pyasn1
#pip is a tool for installing packages from the Python Package Index.
#virtualenv is a tool for creating isolated Python environments containing their own copy of python, pip,
#and their own place to keep libraries installed from PyPI.
#init project specific env, run virtualenv env to create a new environment inside a directory called env.
cd ~/code/myproject/
virtualenv env
#source to use env/bin/pip, notice this only last for this terminal session
source env/bin/activate
#check to see which python is using
which python
#restore to use the system's python
deactivate
#generate requirement.txt, NOTICE if not using virtualenv, this will generate all the package in the system even if you are not using it
pip freeze > requirements.txt
#search for package
pip search
#install dependencies from setting file
#env/bin/pip install -r requirements.txt
# fix up an environment to make it relocatable
# Note: you must run this after you've installed any packages into the environment.
# If you make an environment relocatable, then install a new package, you must run virtualenv --relocatable again.
virtualenv --relocatable env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment