Tag archive for: Python 3

How to setup Raspbian Stretch on Raspberry Pi 3 for developing Python 3 applications

Previously, I had shared:

Although Raspbian Stretch Lite is ideal for running Python 3 applications on Raspberry Pis, it is not so handy for developing Python 3 applications.

For example, if you are building a Python application that interfaces with the GPIO ports and CSI camera of your Raspberry Pi 3, it is hard to test it out on Raspbian Stretch Lite.

Since Raspbian Stretch includes a desktop environment, it is more convenient for developing Python 3 applications for Raspberry Pi. With this purpose in mind, this is how to setup Raspbian Stretch on Raspberry Pi 3 for developing Python 3 applications.

How to create a virtual environment for your Python 3 application with python3-venv in Linux or Unix

The python3-venv module allows us to create lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Given that, we will be able to run multiple Python 3 environments with varying dependencies on the same computer.

This post shows how to create a virtual environment for your Python 3 application with python3-venv in Linux or Unix.

How to setup Jupyter Notebook on Ubuntu 16.04 of your Nvidia Jetson TX2 developer kit

When you want to quickly test out your machine learning algorithm, you can create Python 3 notebooks via Jupyter Notebook.

Therefore, Jupyter Notebook is one of the things that you may want to setup after getting started with your Nvidia Jetson TX2 developer kit.

With this in mind, this post shows how to setup Jupyter Notebook on Ubuntu 16.04 of your Nvidia Jetson TX2 developer kit.

How to send an HTTP request to a HTTP Basic Authentication endpoint in Python 3 with requests library

When you are building a Python 3 application for the Internet, you could encounter API endpoints that use HTTP Basic Authentication as the authentication mechanism.

In such a situation, using the requests library in your Python 3 code makes it easier to communicate with those endpoints.

In case you need to build a Python 3 application that sends HTTP request to a HTTP Basic Authentication endpoint, this is how you can do so with the requests library.

How to use a Python 3 virtual environment in Windows 10

When you need each Python 3 application that you are building to run in its own isolated environment, you can turn to virtual environments.

Since Python is available on Windows 10, you can also use virtual environments on Windows 10.

Typically, using a Python 3 virtual environment in Windows 10 involves the following steps:

  1. Installing Python 3 with pip and several features.
  2. Creating a Python 3 virtual environment with Python 3 venv module.
  3. Activating the Python 3 virtual environment.
  4. Installing Python 3 packages that your Python application is using into the virtual environment.
  5. Running your Python 3 application within the Python 3 virtual environment.
  6. Deactivating the Python 3 virtual environment.

How to download a file via HTTP POST and HTTP GET with Python 3 requests library

When you are building a HTTP client with Python 3, you could be coding it to upload a file to a HTTP server or download a file from a HTTP server.

Previously, we discussed how to upload a file and some data through HTTP multipart in Python 3 using the requests library. In this post, let’s see how we can download a file via HTTP POST and HTTP GET.

How to install python3-venv on Ubuntu 16.04

Since Ubuntu 16.04 is a very popular operating system, it is one operating system that you will likely come across when you are building software with Python 3. For example, if you want to get a Nvidia Jetson TX2 developer kit today, you will find yourself dabbling with Ubuntu 16.04.

On the other hand, the venv module of Python 3 is one recommended way to create virtual environments for our Python 3 projects.

In case you need it, this post describes how to install python3-venv on Ubuntu 16.04.

How to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request

When you build an API endpoint that serves HTTP requests to work on long-running tasks, consider using a scheduler. Instead of holding up a HTTP client until a task is completed, you can return an identifier for the client to query the task status later. In the meantime, your HTTP server can offload the task to a scheduler which will complete it and update the status.

When you are building your HTTP server with Python 3 Flask, Flask-APScheduler gives you the facilities to schedule tasks to be executed in the background.

In this post, we look at how we can get Flask-APScheduler to run multiple tasks in parallel, from a single HTTP request.