Python Resources
https://nvie.com/posts/pin-your-packages/
Learn Python with Socratica (YouTube)
The Python Tutorial
Real Python Tutorial
The Hitchhiker's Guide to Python
cntl + alt + s : General --> Change font size (Zoom) with Ctrl+Mouse Wheel <br>
Tools --> Python console <br>
https://hynek.me/articles/python-app-deps-2018/
python3 -m venv ./venv (invoked within a project directory) source venv/bin/activate (activates virtual environment) deactivate (leaves virtual environment) rm -rf venv (destroys virtual environment)
Virtual environments: - keep your project dependencies isolated - help you avoid version conflicts between packages and different version of the Python runtime As a best practice: - use virtual environments for all of your Python projects in order to store their dependencies - and be mindful of what packages you install in a non-virtual environment as such package installs will go into the global environment
Python 3.3+ $ mkdir foobar $ cd foobar $ python3 -m venv venv $ source venv/bin/activate Python 2.x $ pip install virtualenv $ virtualenv venv $ source venv/bin/activate Windows C:\> python -m venv venv C:\> venv\Scripts\activate
pip3 --version pip3 --help pip3 list [--outdated] pip3 install [name] pip3 show [name] pip3 freeze > requirements.txt (captures all dependencies, including secondary dependencies and their exact version numbers) pip3 install -r requirements.txt pip-comipile & pip-sync
Linux (Debian/Ubuntu) $ sudo apt update $ sudp apt install python-pip macOS & Windows Download https://bootstrap.pypa.io/get-pip.py $ python get-pip.py
Linux (Debian/Ubuntu) $ sudo apt update && sudo apt upgrade python-pip macOS $ sudo pip3 install --upgrade pip setuptools Windows: C:\>pip3 install --upgrade pip setuptools
Option 1 (Preferred): PyPI website -> pypi.python.org Option 2 $ pip3 search [name]
$ pip3 install [name]
Examples: $ pip3 install requests==2.1.4 (specific version) $ pip3 install requests>=2,<3 (latest 2.x.x version) $ pip3 install requests~=2.1.4 (any 2.1.X version >= 2.1.4)
$ pip3 install git+https://github.com/user/repo.git@branch More examples: - $ pip3 install git+https://github.com/davidclin/cloudcustodian-policies.git@master (install from branch) - $ pip3 install git+https://github.com/davidclin/cloudcustodian-policies.git@3adef5ca (install from hash) - $ pip3 install git+https://github.com/davidclin/[email protected] (install from tag/release) Note: Handle with care as installing using this approach is typically for accessing the "cutting edge" packages that may still be in development. If possible, try and install packages from PyPI.
$ pip3 list --outdated $ pip3 install --upgrade [name]
$ pip3 uninstall [name] (Note: pip uninstall DOES NOT uninstall secondary dependencies)