<jupyter_start><jupyter_text>Chapter 2. Managing Python Packages 2.1 Overview(1) Python Package* Finding packages* Installing and removing packages(2) Available tools* What to use* What not to use(3) This module does NOT tell the whole story.* To learn how to install packages correctly, view the next module as well! 2.2 Demo: imports and packages<jupyter_code>import sys
sys.path<jupyter_output><empty_output><jupyter_text>Note that* The first path entry is the current directory.* The directory `site-packages` is where we install the 3rd-party Python packages. 2.3 How an installed package is found(1) `sys.path`* List of directories searched for packages* First item: current directory ('.')* Last item: `site-packages`(2) `site-packages`* Third-party packages are installed here.* Location depends on OS, Python version, installation procedure.* Will be somewhere *inside* your Python installation.* May not even be called `site-packages` (Debian: `dist-packages`). 2.4 Packaging: current state of affairs 2.4.1 How to create, distribute, and install packages?(1) Lots of info on the web is outdated or contradictory.(2) Multiple tools:* `distutils`* `setuptools`* `easy_install`* `ez_setup`* `pip`(3) Multiple formats:* egg* wheel* source dist 2.4.2 Preferred tools(1) Python Packaging authority (PyPA)(2) Creating and distributing packages* Use `setuptools`.* For `disutils`: discontinued, merged into `setuptools`.* `easy_install` is inclued in `setuptools`.* See last module of this course(3) Installing packages:* Use `pip`.* With `virtualenv` (see next module). 2.5 Installing `pip`.(1) Starting with Python 3.4, `pip` comes pre-installed.No need to install anything.(2) Python 2 or Python 3 < 3.4* Follow instructions at http://www.pip-installer.org/* Download and run `get_pip.py`.* Linux/Mac users may need to use `sudo`.(3) Mac users using Homebrew (http://brew.sh):Homebrew installs `pip` with Python.(4) Windows users:* `pip` will be in the `Scripts` directory of the Python installation.* Add `C:\PythonXX\Scripts` to your `PATH`. 2.6 Demo: Installing `pip` on Linux or Mac OS```bash Already download get-pip.py` to a local directory.$ sudo python get-pip.pu Install other packages via pip.$ sudo pip install requests```<jupyter_code>import cv2
print(cv2.__version__)<jupyter_output>3.1.0
{'fraction_non_alphanumeric': 0.10923276983094929, 'fraction_numerical': 0.019939315127871695, 'mean_word_length': 5.428969359331476, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '432346', 'license': 'Apache-2.0', 'n_tokens_mistral': 704, 'n_tokens_neox': 649, 'n_words': 290, 'path': 'python/pluralsight-the-python-developers-toolkit/ch02-ManagingPythonPackages.ipynb', 'repo_name': 'renweizhukov/learning-ml', 'size': '2307'}