The Error: “ModuleNotFoundError: No module named ‘google.protobuf'” in Python occurs because you have not installed the ‘protobuf’ package before using the ‘google.protobuf’ module. The simplest way to solve this Error is to set up the ‘protobuf’ package before performing the google.protobuf module. Follow the explanation below to understand better.
What Is The Cause Of This Error?
The ‘protobuf’ package is created by Google and it is used to transfer data. Currently, it is gradually being used more and more because of its speed. The Error: “ModuleNotFoundError: No module named ‘google.protobuf'” in Python happens when you perform the ‘google.protobuf’ module but you have not set up the ‘protobuf’ package.
Look at the example below to understand better.
import google.protobuf
# Print the version of the google.protobuf module.
print(google.protobuf.__version__)
Output
ModuleNotFoundError: No module named 'google.protobuf'
After learning why this Error occurs, we will show you how to solve it in the next title below.
Solve The Error: “ModuleNotFoundError: No module named ‘google.protobuf'” in Python
To solve the Error: “ModuleNotFoundError: No module named ‘google.protobuf'” in Python, you must set up the ‘protobuf’ package before using the ‘google.protobuf’ module. We will share with you how to set up the ‘protobuf’ package in some environments below.
Set up the ‘protobuf’ package in Python 2
You can set up the ‘protobuf’ package in Python 2 by using the pip and running the following command.
pip install protobuf
If you run the command above properly but this package is not installed successfully. You can try to reinstall it by running the following command.
python -m pip install protobuf
Set up the ‘protobuf’ package in Python 3
You can set up the ‘protobuf’ package in Python 3 by using the pip and running the following command.
pip3 install protobuf
If you run the command above properly but this package is not installed successfully. You can try to reinstall it by running the following command.
python3 -m pip install protobuf
Set up the ‘protobuf’ package on Windows OS
Moreover, you can apply this command to set up the ‘protobuf’ package on Windows OS.
py -m pip install protobuf
Set up the ‘protobuf’ package on Anaconda
In addition, you can set up the ‘protobuf’ package on Anaconda by performing this command.
conda install -c conda-forge protobuf
Set up the django-crispy-forms package on Jupyter Notebook or Google Colaboratory
Besides, you can set up the ‘protobuf’ package on Jupyter Notebook or Google Colaboratory by performing this command.
!pip install protobuf
Check whether the ‘protobuf’ package is installed successfully
After performing the ways like above, you can check whether the ‘protobuf’ package is installed successfully in Python. You can check the ‘google.protobuf’ module version with the example below.
import google.protobuf # Print the version of the google.protobuf module. print(google.protobuf.__version__)
Output
4.21.12
Summary
We have shared with you what causes the Error: “ModuleNotFoundError: No module named ‘google.protobuf'” in Python in Python and how to fix it. Each environment has different ways to solve this Error, so you should choose the best way that fits you. Thanks!

My name is Thomas Valen. As a software developer, I am well-versed in programming languages. Don’t worry if you’re having trouble with the C, C++, Java, Python, JavaScript, or R programming languages. I’m here to assist you!
Name of the university: PTIT
Major: IT
Programming Languages: C, C++, Java, Python, JavaScript, R