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 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.
Python 3 install ubuntu linux 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.
![python 3 install ubuntu linux python 3 install ubuntu linux](https://itsfoss.com/wp-content/uploads/2018/10/install-pip-ubuntu.png)
You can use the general stack described in this article to serve the flask applications that you design.
![python 3 install ubuntu linux python 3 install ubuntu linux](https://www.educba.com/academy/wp-content/uploads/2019/11/install-python-on-linux.png)
![python 3 install ubuntu linux python 3 install ubuntu linux](https://i.stack.imgur.com/DC8bk.png)
Flask is a very simple, but extremely flexible framework meant to provide your applications with functionality without being too restrictive about structure and design.