- PIP FLASK PYTHON 3 INSTALL MODULE HOW TO
- PIP FLASK PYTHON 3 INSTALL MODULE INSTALL
- PIP FLASK PYTHON 3 INSTALL MODULE UPDATE
Now that we have Flask available, we can create a simple application.
PIP FLASK PYTHON 3 INSTALL MODULE INSTALL
(flaskprojectenv) $ pip install gunicorn flask Create a Sample App Note: Regardless of which version of Python you are using, when the virtual environment is activated, you should use the pip command (not pip3). Type the following commands to get these two components: We can use the local instance of pip to install Flask and Gunicorn. Now that you are in your virtual environment, we can install Flask and Gunicorn and get started on designing our application: Install Flask and Gunicorn It will look something like this Set Up a Flask Application Your prompt will change to indicate that you are now operating within the virtual environment. This will install a local copy of Python and pip into a directory called flaskprojectenv within your project directory.īefore we install applications within the virtual environment, we need to activate it. We can create a virtual environment to store our Flask project's Python requirements by typing: virtualenv flaskprojectenv Move into the directory after you create it: mkdir ~/flaskproject Now, we can make a parent directory for our Flask project. If you are using Python 3, type: sudo pip3 install virtualenv
Start by installing the virtualenv package using pip. Next, we'll set up a virtual environment in order to isolate our Flask application from the other Python files on the system.
$ sudo apt-get install python3-pip python3-dev nginx Create a Python 3 Virtual Environment
PIP FLASK PYTHON 3 INSTALL MODULE UPDATE
Installing Python 3, type: $ sudo apt-get update The specific packages you need will depend on the version of Python you are using for your project. Update your local package index and then install the packages. We will also get the Python 3 development files needed to build some of the Gunicorn components. We will install pip, the Python 3 package manager, in order to install and manage our Python 3 components. The first step will be to install all of the pieces that we need from the repositories.
# usermod -aG sudo bobby Install the Components from the Ubuntu Repositories By default, on Ubuntu 18.04, users who belong to the sudo group are allowed to use the sudo command. To add these privileges to our new user, we need to add the new user to the sudo group. This user needs to have sudo privileges so that it can perform administrative functions.Ĭreate non-root user with sudo privileges configured: Prerequisitesīefore starting on this article, you should have a non-root user configured on your server.
PIP FLASK PYTHON 3 INSTALL MODULE HOW TO
The bulk of this article will be about how to set up the Gunicorn application server to launch the application and Nginx to act as a front-end reverse proxy. In this article, we will be setting up a simple Python application using the Flask micro-framework on Ubuntu 18.04. You can use the general stack described in this article to serve the flask applications that you design. Flask is a very simple, but extremely flexible framework meant to provide your applications with functionality without being too restrictive about structure and design.