Last active
March 5, 2018 01:54
-
-
Save rosswd/ada677a48e81c2f37540230967346f5d to your computer and use it in GitHub Desktop.
Using pip, virtualenv and/or virtualenvwrapper to manage packages and environments in python.
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
# know what version of python you have | |
python # os (2.7.10) | |
python2 # homebrew python 2 (2.7.14) | |
python3 # homebrew python 3 (3.6.2) | |
# install pipenv | |
pip3 install pipenv | |
export PATH=$PATH:$HOME/Library/Python/3.6/bin >> ~/.bash_exports | |
# use | |
mkdir myproject | |
cd myproject | |
pipenv install requests | |
vim main.py | |
pipenv run python main.py | |
cat Pipfile | |
#pipenv shell |
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
# project directory and environment creation | |
# one time set up for project setup | |
vim .bash_profile | |
export PROJECT_HOME=$HOME/Sites/python | |
source .bash_profile | |
# workflow for project | |
mkproject webthingy | |
deactivate | |
# managing environments | |
rmvirtualenv <venv> | |
lsvirtualenv |
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
# using virtualenv | |
# one time set up for virtualenv | |
pip install virtualenv | |
# workflow for virtualenv | |
mkdir <project_name> | |
cd <project_name> | |
virtualenv <some-env> | |
cd <some-env> | |
source bin/activate | |
pip install <package1 package2 etc> | |
pip freeze > requirements.txt | |
deactivate |
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
# one time set up for virtualenvwrapper | |
pip install virtualenvwrapper | |
export WORKON_HOME=~/Envs | |
source /usr/local/bin/virtualenvwrapper.sh | |
source ~/.bash_profile | |
# workflow for virtualenvwrapper | |
mkvirtualenv webscrape-stack | |
pip install requests beautifulsoup4 | |
pip freeze > requirements.txt | |
deactivate | |
workon webscrape-stack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment