Make sure you quit Flask's development server. Remember that you just need to press
Ctrl
+
C
in the Terminal or Command Prompt window in which it is running. Now, we will install many additional packages. Make sure you have activated the virtual environment we have created in the previous chapter and we named Flask01
. In case you created a new virtual environment to work with this example or you downloaded the sample code for the book, make sure you install the packages we used in the previous example.
After you activate the virtual environment, it is time to run commands that will be the same for either macOS, Linux, or Windows. We can install all the necessary packages with pip with a single command. However, we will run independent commands to make it easier to detect any problems in case a specific installation fails.
Now, we must run the following command to install Flask-SQLAlchemy with pip. Flask-SQLAlchemy adds support for the SQLAlchemy ORM to Flask applications. This extension simplifies executing common SQLAlchemy tasks within a Flask application. SQLAlchemy is a dependency for Flask-SQLAlchemy, and therefore, pip will install it automatically, too:
pip install Flask-SQLAlchemy
The last lines of the output will indicate all the packages that have been successfully installed, including SQLAlchemy
and Flask-SQLAlchemy
:
Installing collected packages: SQLAlchemy, Flask-SQLAlchemy Running setup.py install for SQLAlchemy Running setup.py install for Flask-SQLAlchemy Successfully installed Flask-SQLAlchemy-2.1 SQLAlchemy-1.0.14
Run the following command to install Flask-Migrate with pip. Flask-Migrate uses the Alembic package to handle SQLAlchemy database migrations for Flask applications. We will use Flask-Migrate to set up our PostgreSQL database. Flask-Script is one of the dependencies for Flask-Migrate, and therefore, pip will install it automatically. Flask-Script adds support for writing external scripts in Flask, including scripts to set up a database.
pip install Flask-Migrate
The last lines for the output will indicate all the packages that have been successfully installed, including Flask-Migrate
and Flask-Script
. The other installed packages are additional dependencies:
Installing collected packages: Mako, python-editor, alembic, Flask-Script, Flask-Migrate Running setup.py install for Mako Running setup.py install for python-editor Running setup.py install for alembic Running setup.py install for Flask-Script Running setup.py install for Flask-Migrate Successfully installed Flask-Migrate-2.0.0 Flask-Script-2.0.5 Mako-1.0.4 alembic-0.8.7 python-editor-1.0.1
Run the following command to install marshmallow with pip. Marshmallow is a lightweight library for converting complex datatypes to and from native Python datatypes. Marshmallow provides schemas that we can use to validate input data, deserialize input data to app-level objects, and serialize app-level objects to Python primitive types:
pip install marshmallow
The last lines for the output will indicate marshmallow
has been successfully installed:
Installing collected packages: marshmallow Successfully installed marshmallow-2.9.1
Run the following command to install Marshmallow-sqlalchemy with pip. Marshmallow-sqlalchemy provides SQLAlchemy integration with the previously installed marshmallow validation, serialization, and deserialization lightweight library:
pip install marshmallow-sqlalchemy
The last lines for the output will indicate marshmallow-sqlalchemy
has been successfully installed:
Installing collected packages: marshmallow-sqlalchemy Successfully installed marshmallow-sqlalchemy-0.10.0
Finally, run the following command to install Flask-Marshmallow with pip. Flask-Marshmallow integrates the previously installed marshmallow
library with Flask applications and makes it easy to generate a URL and Hyperlink fields:
pip install Flask-Marshmallow
The last lines for the output will indicate Flask-Marshmallow
has been successfully installed:
Installing collected packages: Flask-Marshmallow Successfully installed Flask-Marshmallow-0.7.0
3.145.174.253