About general things in Python: from setup to usage
Last active
December 20, 2020 22:19
-
-
Save sarveshseri/3b32f3485248141e008eb61bce2942ac to your computer and use it in GitHub Desktop.
Python Related
Install python 3 with homebrew. This will also setip pip for us.
brew install pythonAdd new installed python to the top of your Path
export PATH="/usr/local/opt/python/libexec/bin:$PATH"Install with pip .
pip install virtualenvpip install virtualenvwrapperAdd following to your .bashrc or .zprofile .
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/opt/python/libexec/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh# Create a virutal env in $WORKON_HOME
mkvirtualenv my_env
# Exit out of the current Python virtual environment
deactivate
# List available virtual environments
workon
# Activate the specified Python virtual environment
workon name_of_environment
# Remove the specified environment
rmvirtualenv name_of_environment
pipenvis slow... really slow...
pipenv can be thought of as the missing project package manager for python.
Its an improved and feature rich alternative to the older pip + requirements.txt combination.
It creates Pipfile and Pipfile.lock files which keep track of dependencies required for the project.
pip install pipenv# to install and add a dependency
pipenv install django
# to install and add a dependency with specific version
pipenv install django==3.0.8
# to install and add a dev-dependency
pipenv install pytest --dev
# to generate/update lockfile
pipenv lock
# install project dependencies
pipenv install
# install project dev-dependencies
pipenv install --dev
# install locked project dependencies
pipenv install --ignore-pipfile
# check the dependency graph
pipenv graph
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment