Tag archive for: Python 3

How to use the MCP3008-I/P chip to help your Raspberry Pi read digital data from analog sensors

Although your Raspberry Pi is unable to read analog input out of the box, you can get a MCP3008 I/P ADC chip to help your Raspberry Pi do so.

MCP3008 IP ADC chip up close

When you connect a MCP3008 I/P chip to your Raspberry Pi, you can read up to 8 analog inputs with SPI.

Given these points, this post will show you how you can use the MCP3008 I/P chip to help your Raspberry Pi read digital data from analog sensors.

How to use Python 3 virtual environments to run Python 3 applications on your Raspberry Pi

Whenever I am working on a Python 3 project, I will always use a Python 3 virtual environment for running that project. Therefore, I tend to do the same when it comes to .

If you are looking to build Python 3 applications to run on your Pi, then you may find this article useful for you.

How to send a HTTP request with client certificate + private key + password/secret in Python 3

When we need to create a HTTP client that communicates with a HTTP server through certificate-based authentication, we will typically have to download a certificate, in .pem format, from the server.

After we had downloaded the .pem file, the HTTP client will use the private key and certificate to authenticate itself with the HTTP server. Sometimes, the HTTP client will need to decrypt the private key with a password/secret first.

So with a .pem file and a password/secret, how can you create a HTTP client in Python 3 to send a HTTP request to the HTTP server?

In case you need it, this post shows how to send a HTTP request with client certificate + private key + password/secret in Python 3.

How to solve “No API definition provided” error for Flask-RESTPlus app on Cloud Foundry

When you create an API endpoint that generates a QRCode with Flask-RESTPlus, you may want to deploy it onto Cloud Foundry.

However, when I first tried to do so, I was greeted with a No API definition provided when I accessed the Swagger Api portal page.

qrcodeapp showing No API definition provided

So why is there a “No API definition provided” error for Flask-RESTPlus app on Cloud Foundry?

In case you are facing such a problem, this post discuss how I had managed to solve the “No API definition provided” error for my Flask-RESTPlus app on Cloud Foundry.

How to use NSSM to setup Jupyter Notebook as a Windows Service running its own Python 3 virtual environment

When you take Andrew Ng’s Deep Learning Coursera course, you can get a better understanding of deep learning. In addition, you will get many Jupyter Notebook documents that you can reference while building models that can solve interesting problems.

When you want to readily access those documents, you can setup Jupyter Notebook as a Windows Service on your Windows machine.

As I had mentioned in how to use NSSM to run a Python 3 application as a Windows Service in its own Python 3 virtual environment, NSSM is a very helpful tool for us to create Windows Services.

Since we can install Jupyter Notebook via pip, we can run Jupyter Notebook from its own virtual environment. In addition to that, since we can create a Python 3 virtual environment in Windows 10, we can setup Jupyter Notebook as a Windows Service running its own Python 3 virtual environment.

Given these points, let us look at how we can use NSSM to setup Jupyter Notebook as a Windows Service running its own Python 3 virtual environment.

How to use NSSM to run a Python 3 application as a Windows Service in its own Python 3 virtual environment

If you want to run a Python 3 application as a Windows Service, then you are going to love NSSM. Since NSSM handles the life cycle of a Windows Service for our Python 3 application, we can keep it platform agnostic.

Previously, we saw how we can use a Python 3 virtual environment in Windows 10. Given that, let’s see how we can use NSSM to run a Python 3 application as a Windows Service in its own Python 3 virtual environment.

How to create an API endpoint that generates a QR Code image, with Python 3 Flask-RESTPlus and python-qrcode

When you have an API endpoint that generates a QR Code image, another device with a QR Code scanner will be able to get the encoded value to perform some action. For example, WhatsApp web generates a QR Code image that encodes a code for WhatsApp app to sign in the user.

So how can you create an API endpoint that generates a QR Code image? With this in mind, let’s look at how we can do so with Python 3 Flask-RESTPlus and python-qrcode.

How to prepare a virtual environment to run a gpiozero based project on Raspbian Stretch

When you use a virtual environment to run your application, you isolate the dependencies in its own container.

In such a situation, you can ensure that your application can run alongside other applications with incompatible dependencies.

Therefore, I always favour the use of virtual environment for running my Python applications.

With this in mind, this is a story about preparing a virtual environment to run a gpiozero based project on Raspbian Stretch.

Getting the environment variables supplied to your Cloud Foundry application with Python 3 Flask

When I was trying to build a Python 3 Flask application on Cloud Foundry, I wanted to quickly check the environment variables that Cloud Foundry will supply to my application.

As a result of that, I created a Python 3 Flask application that will probe the environment variables that it receives from Cloud Foundry.

This post lists the files that constitute that Python 3 Flask application.