Last modified: Jun 01, 2025 By Alexander Williams
How to Install Pygal in Python Easily
Pygal is a Python library for creating SVG charts. It is simple and powerful. You can make beautiful charts with minimal code.
In this guide, you will learn how to install Pygal in Python. We will cover different installation methods and a quick example.
Prerequisites
Before installing Pygal, ensure you have Python installed. You can check by running:
python --version
If Python is not installed, download it from the official website. Pygal works with Python 3.6 and above.
Install Pygal Using pip
The easiest way to install Pygal is using pip. Open your terminal or command prompt and run:
pip install pygal
This will download and install Pygal and its dependencies. Wait for the process to complete.
Verify the Installation
To ensure Pygal is installed correctly, run the following command:
python -c "import pygal; print(pygal.__version__)"
If installed correctly, it will display the Pygal version. For example:
3.0.0
Install Pygal in a Virtual Environment
Using a virtual environment is a good practice. It keeps your projects isolated. First, create a virtual environment:
python -m venv myenv
Activate the virtual environment:
# On Windows
myenv\Scripts\activate
# On macOS/Linux
source myenv/bin/activate
Now, install Pygal inside the virtual environment:
pip install pygal
Basic Pygal Example
Let's create a simple bar chart using Pygal. This will help you understand how it works.
import pygal
# Create a bar chart
bar_chart = pygal.Bar()
# Add data
bar_chart.title = "Fruits Consumption"
bar_chart.add("Apples", 15)
bar_chart.add("Oranges", 12)
bar_chart.add("Bananas", 8)
# Save the chart
bar_chart.render_to_file("fruits_chart.svg")
This code creates a bar chart and saves it as an SVG file. Open the file in a browser to see the chart.
Common Issues and Fixes
Sometimes, you may face issues while installing Pygal. Here are some common problems and solutions.
1. Permission Denied Error: If you get a permission error, try using:
pip install --user pygal
2. Outdated pip: Ensure pip is up to date. Run:
pip install --upgrade pip
3. Missing Dependencies: Pygal may need additional libraries. Install them if needed.
Conclusion
Installing Pygal in Python is simple. Use pip install pygal
to get started. Pygal is great for creating charts and graphs.
For more Python libraries, check out our guides on Install MoviePy in Python Easily and Install pySerialTransfer in Python Easily.
Now you can start creating beautiful charts with Pygal. Happy coding!