- PIP
- Virtualenv
- virtualenvwrapper
- PIP
- Packages - file,download and install
- Manage
- Virtual Env
- Project specific dependencies context
- Virtualenvwrapper
- Making venv more convinient(#modular_func)
Thirdparty dependency library package manager. Always Install pip on venv and not pollute different projects
https://pypi.org - list of all available libraries
- Find , Download , Install
- Manage
Check if pip is installed:
pip -V
pip list
pip uninstall
pip show
python3 -m pip list
python -m pip list
python3 -m install
python -m install
sys.path = '','/usr/lib/python3.7','usr/local/lib/python2.7/dist-packages'
pip show
Shows the location as :
Location: /Library/Python/2.7/site-packages
Isolated context for installing packages. Always work inside venvs.
Contain packages,tools,python etc
Keep them separate from Project source code.
sudo python -m pip install virtualenv
mkdir -p ~/venvs
Inside the venvs folder use the virtualenv command to create as many.
It will create dedicated python interpretor / pip and libraries
virtualenv -p python3 basepython3
Go inside the bin folder and run the activate which activates this venv.
On linux/Mac OS
. ~/venvs//bin/activate
Now when we run python or pip , it will refer to the version in this venv
python -V OR pip -V
python -m pip list
. ~/venvs//bin/deactivate
python -m pip freeze > requirements.txt
To import the dependencies used in another environment to current use the requirements.txt as
python -m pip install -r requirements.txt
SPECIFYING VERSIONS in requirements.txt
module == 1.2.1
module >= 1.2.1
module != 1.2.1
What happens when we work on an external project like flask ?
-
Requirements.txt is for your own development and sharing between co-developers.we have control over runtime env.
-
git clone <https://github.com/pallets/flask
-
Special file --> setup.py
this file has a section : install_requires[] -
If doing local development of such a project , and dont need the external flask but from my code base :
python -m pip install -e flask
-
tox.in (auto setup varying environments and run unit tests on all )
- User firndly wrapper of virtualenv
- Bind projects with virtualenv