Frappe Frameworkbash

How to Fix 'ModuleNotFoundError: No module named psutil' in Frappe Bench?

Error: No module named psutil

Resolve the common 'ModuleNotFoundError: No module named psutil' in Frappe and ERPNext by installing the psutil dependency within your bench's virtual environment using pip.

When working with the Frappe Framework, you might encounter a `ModuleNotFoundError: No module named 'psutil'`. This error typically occurs when starting the bench (`bench start`) or running other bench commands. It indicates that a required Python package, `psutil`, is missing from your bench's virtual environment. `psutil` is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors), and it is a crucial dependency for Frappe's process management.

The following commands show the standard procedure to correctly install or upgrade the `psutil` package within the isolated Python environment of your `frappe-bench`, resolving the error.

bash
1$ cd frappe-bench/
2$ source env/bin/activate
3$ pip install --upgrade psutil
4$ sudo pip install --upgrade psutil

Understanding This Code

What It Does

This set of commands installs the `psutil` Python package into the active Frappe bench virtual environment, resolving the 'No module named psutil' error.

When To Use

Use this solution when you see a `ModuleNotFoundError` for `psutil` while running `bench start`, `bench update`, or any other bench command.

Prerequisites

  • Access to the server terminal where your Frappe bench is installed.
  • Sudo privileges may be required for a system-wide installation attempt.

Key Concepts

Important ideas to understand in this code

Frappe Bench Virtual Environment

Each Frappe bench (`frappe-bench`) contains its own isolated Python virtual environment, typically located in the `env/` directory. It's crucial to install Python dependencies inside this specific environment to ensure they are available to Frappe and ERPNext processes. Activating it with `source env/bin/activate` is the first step before using `pip`.

Learn more

pip - Python Package Installer

`pip` is the standard package manager for Python. When the virtual environment is active, running `pip install <package-name>` installs the package locally into that environment, not globally on the system. The `--upgrade` flag ensures you get the latest compatible version.

Learn more

Step-by-Step Tutorial

Follow along to understand how this code works

1

Navigate to Your Bench Directory

Open your terminal and change your current directory to the root of your Frappe bench. This is where the virtual environment folder (`env`) is located.

bash
$ cd frappe-bench/
Next Step
2

Activate the Virtual Environment

Before installing any packages, you must activate the bench's virtual environment. This ensures that `pip` installs packages in the correct isolated location. Your terminal prompt will usually change to indicate that the environment is active.

bash
$ source env/bin/activate
Next Step
3

Install psutil using pip

With the virtual environment active, use `pip` to install the `psutil` package. The `--upgrade` flag ensures that if it's already installed but outdated, it will be updated to the latest version.

bash
$ pip install --upgrade psutil

Common Issues & Solutions

Troubleshoot problems you might encounter

Talk to our Experts

Ready to Scale with Smart Tech? Let's Talk.

Transform your business processes with AI-powered automation and expert implementation.

Trusted by 100+ businesses

Frequently Asked Questions

Find answers to common questions about our services

Still have questions?

Contact Support

Book a Free Consultation

Get started with your free demo today and discover how our solutions can transform your business

Quick Response
Free Consultation

Get Started Today

Fill out the form below and we'll get back to you within 24 hours

By submitting this form, you agree to our privacy policy and terms of service.

How to Fix 'ModuleNotFoundError: No module named psutil' in Frappe Bench?