This article will show the solutions to fix Modulenotfounderror: no module named psutil.
Also, we will provide what are the root causes of this error.
Since the Python psutil is one of the libraries with more than 26,414,759 downloads.
Thus we will cover a guide on how to install it in different types of python environments.
What is Modulenotfounderror no module named psutil?
Technically, the ModuleNotFoundError: No module named ‘psutil’ is an error that can occur when running a Python script or module.
Wherein it requires the “psutil” module to be present, but it is not found.
The error message indicates that the Python interpreter is unable to locate the “psutil” module and therefore cannot import it into the script.
Therefore as we go along we listed here the common root causes of why you encountered this error as well as it could be easy to troubleshoot the error.
Common causes of Modulenotfounderror: no module named psutil error
Here are some common causes of this error:
- The “psutil” module is not installed in the current Python environment.
- The Python interpreter being used to run the script is not the same one where “psutil” is installed. Make sure you are using the correct Python interpreter.
- The module installation is corrupted.
- The module is installed in a virtual environment that is not currently activated. You need to activate the virtual environment before running the script.
- The module is installed in a non-standard location that is not in the PYTHONPATH environment variable.
How to fix this modulenotfounderror no module named psutil
As mentioned above typically the “ModuleNotFoundError: No module named ‘psutil'” error occurs when the ‘psutil’ module is not installed in your Python environment.
Here are a few steps you can take to fix the issue:
- Install the ‘psutil’ module using pip
Open your command prompt or terminal and run the following command:
pip install psutil - Check the Python version and make sure you are using the correct version of Python.
If you have multiple versions of Python installed on your system, try running the command with the specific version of Python you want to use.
For example:
pip3 -m pip install psutil
or to check python version use this command
python –version
In order to fix this error we need to install the psutil module, so we will see here a lot of ways how to install the module.
How to install psutil in Windows
When you are using windows here are the steps to install psutil module:
- Head over to the search bar and type cmd then press Enter.
- Once the cmd opens, type the pip install psutil command and press Enter.
This will install the pip psutil in your python installation process.
- If you have Python 2 or Python 3 the command above probably will not work. Alternatively, use this command “pip3 install psutil” or “python -m pip install psutil .
Note. Wait for the installation complete. Then, verify if it is installed on your computer.
How to install psutil in Linux
psutil can be installed on Linux in four steps, here’s how:
- Open your Linux terminal or shell
- Input “pip install psutil” (without quotes), press Enter.
- If it doesn’t work, try “pip3 install psutil” or “python -m pip install psutil“.
- Wait for the installation to terminate successfully.
The psutil module should be installed successfully.
How to install psutil in macOS
Just like in Linux, we can install psutil in macOS within 4 easy steps.
- Open your macOS terminal.
- Input pip install psutil and press Enter.
- If it will not work, try “pip3 install psutil” or “python -m pip install psutil“.
- Wait for the installation to terminate successfully.
Now the package is now installed on your macOS.
How to install psutil in Jupyter
In installing any packages in Jupyter Notebook however, requires to prefix the command !pip install my_package with the exclamation mark.
Hence, it works on psutil library too.
- !pip install psutil
Conclusion
In conclusion this article Modulenotfounderror: no module named psutil provided possible solutions in fixing the error.
If you follow the solution, it will solve the error that you are facing right now. It is a simple solution, yet literally effective in solving the `error.
We hope that this article has provided you with the information you need to fix this error and continue working with Python packages.
If you are finding solutions to some errors you’re encountering we also have Modulenotfounderror no module named tensorflow contrib.