Skip to content

Instantly share code, notes, and snippets.

@kezzico
Last active October 29, 2023 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kezzico/63056f2c686dabe17b9afff03c69b9dc to your computer and use it in GitHub Desktop.
Save kezzico/63056f2c686dabe17b9afff03c69b9dc to your computer and use it in GitHub Desktop.
Python: All About Packages

Python: All About Packages

Packages are a neat way for coders to quickly extend their project's capabilities. At its core, Python is a programming langauge like any other. It does not have an HTTP server, AI training modules, or even the data analysis tools that Python is known for. These all come from packages.

Python packages are hosted on PyPi.org. PyPI is an open source project developed under the umbrella of the Python Packaging Authority (PyPA) and supported by the Python Packaging Working Group.

Popular Packages

Here are just a few packages that you can download into your Python Environment.

Pandas

Pandas is a Python package that provides fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive.

PyTorch

Accelerate neural network training with tensors optimized for the CPU or the GPU. PyTorch provide a wide variety of tensor routines to accelerate and fit your scientific computation needs such as slicing, indexing, mathematical operations, linear algebra, reductions. And they are fast!

Flask

Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.

Beautiful Soup

Beautiful Soup is a library that makes it easy to scrape information from web pages.

NumPy

The Excel of the coding world. NumPy provides high level APIs for reading and manipulating tabular data. NumPy is a tool fit for both large and small data sets. It can effectively aggregate and query data in common data formats including CSV and TXT.

Installation

There are two ways to install a package.

The first is to install the package into your system environment. I do not recommend this approach. However, it is the default. And there are several use cases where this can be useful.

The second is to install the package into a virtual environment. If you don't know how, read Python: Setup a Virtual Environment. Basically, a virtual environment is a self-contained directory or folder.

In either case, the process is the same.

pip install <package>

for example

pip install torch

After a few moment, pip has finished downloading the package into your environment. There should be a mess of new files added to your project's folder. bin/ lib/ include/ etc...

By adding the package to your environment, Python can now access the capabilities of the package using the special keyword import.

import torch
import torch.nn as nn
import torch.optim as optim

And that's it!

The specifics of each package can be found by reading the respective documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment