Error : No module named 'psutil'
Asked Answered
J

11

26

I've been trying to install Peter Chervenski's MultiNEAT and ran into a problem while running setup.py (python setup.py build_ext):

File "c:/Users/1234/Documents/Alex/multineat/peter-ch-MultiNEAT-f631e2f/setup.py", line 7, in from site-packages import psutil'

And I made sure this module is installed: used pip install a couple of times and it said:

Requirement already satisfied: psutil in c:\users\1234\appdata\local\programs\python\python36-32\lib\site-packages

And I checked this directory myself and found psutil module there (I even deleted it and reinstalled one more time). And after that, I still got the same error with Python not seeing psutil. Is there any way I can solve this problem? (I am using Windows 10, latest version of Python)

Jeopardous answered 13/5, 2018 at 12:56 Comment(2)
Are you missing an import statement in your script?Hobbledehoy
No, I am not missing it. I do have an import segment "import psutil".Jeopardous
M
19

Error I got in windows 10 while executing a python script ->

Traceback (most recent call last):

File "C:\Users\YOUR NAME\Desktop\Sample.py", line 2, in import psutil

ImportError: No module named psutil

This is how I resolved the issue ->

C:\python -m pip install --upgrade pip

[Latest pip version got installed successfully]

C:\>python -m pip install psutil

Collecting psutil
  Downloading https://files.pythonhosted.org/packages/50/6a/34525bc4e6e153bf6e849a4c4e936742b365f6819c0462cebfa4f082a3c4/psutil-5.4.7-cp27-none-win_amd64.whl (220kB)
    100% |UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU| 225kB 696kB/s
Installing collected packages: psutil
Successfully installed psutil-5.4.7

Finally, Sample.py got executed successfully

Motherofpearl answered 11/9, 2018 at 5:54 Comment(0)
P
18

This worked for me..

sudo pip install --upgrade psutil
Pelvic answered 20/12, 2019 at 11:23 Comment(0)
C
16

Follow these steps on windows:

  1. Open command prompt in administrator mode
  2. Enter Command python -m pip install psutil
  3. Upgrade pip if outdated python -m pip install --upgrade pip

Process Example

Cryoscope answered 10/1, 2020 at 8:12 Comment(0)
J
7

I solved a problem and if you had a similar problem you should try this:

  1. upgrade pip to the latest version (python -m pip install --upgrade pip)
  2. delete psutil (C:\Users\(your username)\AppData\Local\Programs\Python\Python36-32\Lib\site-packages) if you have it installed already
  3. reupload psutilnow using pip install psutil

. It helped me and if you have a permission error, try opening cmd as administrator.

Jeopardous answered 13/5, 2018 at 17:36 Comment(2)
Or windows powershell. Worked fine.Fail
For those who, like me, didn't know what was meant by "delete psutil", it means literally just "rm -rf" the directory. After that, you're free to install it with pip.Dunseath
D
1

I had that problem trust me this works 100%. I am using VS Code you just have to install it with pip normally but sometimes it doesn't add it to your working directories (venv\lib\site-packages\) folder your editor is using. So just copy and paste it there from here C:\Users\(your username)\AppData\Roaming\Python\Python39\site-packages

Dibranchiate answered 30/12, 2020 at 18:15 Comment(0)
S
1

I resolved this issue as below: It seems, every time i was trying to upgrade psutil using "pip install psutil" it just showing the requirement is satisfied and showing 5.7.2.

  1. Go to the folder where Python is install and psutil is available e.g. "C:\Python\Lib\site-packages"
  2. find all psutil related filesand rename them to something else e.g. Old__psutil Old_psutil-5.7.2.dist-info
  3. Run "pip install psutil" from bash or command line
  4. It updated for me to 5.8.0

This resolved my issue.

Schoolbag answered 31/3, 2021 at 22:23 Comment(0)
S
0

Inconsistencies can happen if you have multiple versions of windows installed on your system. Check for the default python directory path and make sure 'psutils' is updated in that directory.

Selway answered 15/11, 2020 at 6:40 Comment(0)
A
0

I got the same issue and solved it by specifying the exact (virtual environment / global) pip you are using. In my case (using a virtual environment), after executed pip by using the absolute path, I installed psutil successfully.

psutil issue

Appellant answered 25/12, 2020 at 5:17 Comment(0)
S
0

These two commands typed in the SSH shell worked for me. The apt install is what was showing me the error mentioned.

sudo apt install pip
python3 -m pip install psutil

Result: python3 -m pip install psutil Collecting psutil Downloading psutil-5.9.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (284 kB) |████████████████████████████████| 284 kB 2.0 MB/s Installing collected packages: psutil Successfully installed psutil-5.9.1

Hope this helps someone...

Scrogan answered 30/7, 2022 at 2:22 Comment(0)
B
0

I was having same issue, but not quite exactly the same circumstances. I am writing this for any people that have the same problem as I did.

I was running sudo python script.py (sudo was needed since I wanted to alter cpu frequencies) but Error : No module named 'psutil' appeared. I checked my python version with

python --version

and it was 3.8, but when I checked my version with

sudo python --version

it was running version 2.7. Once I ran

sudo python3 script.py

it ran smoothly. Of course I had already verified I had the newest pip installed + psutil library installed on python3. Basically, make sure you are running the correct python version and you have all libraries/package managers up to date, hope this helped!

Bettor answered 4/2, 2023 at 2:21 Comment(0)
A
-1

This worked for me. I had multiple version of python in my ubuntu system.

$ sudo apt install python3.6-dev
Alberic answered 5/11, 2020 at 10:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.