Last active
October 2, 2015 17:30
-
-
Save kittolau/d474d6806acdbb34a0dc to your computer and use it in GitHub Desktop.
virtualenv cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#To solve the InsecurePlatformWarning | |
#========================================== | |
#for ubuntu | |
sudo apt-get install libffi-dev libssl-dev | |
pip install pyopenssl ndg-httpsclient pyasn1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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