Open In App

Python Pyramid – Environment Setup

Last Updated : 10 Dec, 2023
Like Article

Python Pyramid, often simply referred to as Pyramid, is an open-source web framework used for building web applications and web services in Python. Whether you’re constructing a website, or a sophisticated web application Pyramid offers the resources and adaptability to complete the task effectively.

Environment Setup for Python Pyramid

To begin with, let’s go through the step-by-step process of setting up a development environment for Python Pyramid.

Step 1: Install Python

If you haven’t installed Python yet you can download the Python, for Windows from the Python website (https;// Remember to include Python in your system’s PATH when installing it.

Step 2: Create a directory

Once Python is installed, create a new directory for your Pyramid project and navigate to it in the command prompt.

cd <pyramid_directory>

Step 3: Create and Activate Virtual Environment

Let’s create and activate a virtual environment for your Pyramid project. we can create a virtual environment using Python’s vene. It is a Python built-in module that stands for “virtual environment.” It is used to create isolated Python environments in which you can install packages and dependencies independently of the system-wide Python installation. To create a virtual environment follow these steps.

Step 4: Install Pyramid

Once you’ve activated the environment, you can proceed to install Pyramid with version by using the following pip command”.

>pip install "pyramid==2.0"

Note: It is not necessary to specify the version



Step 5: Create a Pyramid Application

We are using Cookiecutter for creating the Pyramid application. Because it streamlines the process of generating a Pyramid project template with predefined configurations, folder structures, and sample code. Cookiecutter templates provide a consistent and efficient way to set up Pyramid projects by eliminating the need to manually create directories and files and configure settings from scratch.

Install cookiecutter if you don’t have it installed using following command.

>pip install cookiecutter 

Then, run the following command in command prompt for creating your Pyramid application.

>cookiecutter gh:Pylons/pyramid-cookiecutter-starter

Then it will ask following things

  • project_name (Pyramid Scaffold): Give your own project name
  • repo_name( project_name): Give repo name.
  • Select template_language: Select one template language among follwing
    • 1 – jinja2
    • 2 – chaymeleon
    • 3 – mako
  • Select backend: Select One backend
    • 1 – none
    • 2 – sqlalchemy
    • 3 – zodb


Step 6: Navigate to new Project

Change directory into your newly created project using following command

cd <project_name>
cd hello

Step 7: Install Required Dependencies

Install the project in required modules using command

pip install -e .

Step 9: Initialize and upgrade the database using Alembic

Run the following two commands for initializing and upgrade the database.

alembic -c development.ini revision --autogenerate -m "init"
alembic -c development.ini upgrade head


Step 10: Load data into DB

Load default data into the database using a script.

initialize_<project_name>_db development.ini

Step 12: Run your project

Run the command for start the Pyramid.

 >pserve development.ini


Starting server in PID 6264.
2023-10-25 17:27:02,347 INFO  [waitress:486][MainThread] Serving on http://[::1]:6543
2023-10-25 17:27:02,347 INFO  [waitress:486][MainThread] Serving on

The above command will start the pyramid server in localhost in 6543 port

Step 13: Access Your Pyramid Application

Open a web browser and go to http://localhost:6543 or the URL specified in the console. You should see your Pyramid application running.

Step 14: Stop server

Use the ctrl+c for stopping the pyramid server.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads