Home > Enterprise >  No module named 'psutil', although it is installed (MacOS)
No module named 'psutil', although it is installed (MacOS)

Time:07-23

When I run my code that includes psutil module I encounter the following error:

Traceback (most recent call last):
  File "/Users/alek/Desktop/coloring/solver.py", line 4, in <module>
    from psutil import cpu_count
ModuleNotFoundError: No module named 'psutil'

Although, when trying to install the module in terminal, I can see the following

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: psutil in /opt/homebrew/lib/python3.9/site-packages (5.9.1)
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
WARNING: There was an error checking the latest version of pip.

How should I ensure that the module is in the right environment and can be used by my program?

Thanks in advance!

CodePudding user response:

try to upgrade it

sudo pip install --upgrade psutil

CodePudding user response:

try to run this command in python shell import site; site.getsitepackages()

actually, it is trying to search psutil module in one of the Xcode path.

see if you have psutil in this path. /Applications/Xcode_13.4.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages

if not add the psutil module here and it should work. it worked for me.

  • Related