OiRc
OiRc

Reputation: 1622

issue on import psutil inside python script

i'm not able to import psutil inside my scripts. But the library is installed on my machine.

my library is inside this directory, on which there is also simplejson library:

usr/local/lib/python2.7/site-packages/psutil

But if i create a script for example this:

#!/usr/bin/python


import psutil
import simplejson as json



print("Hello, world!")

i get this errors:

File "test.py", line 4, in <module>
    import psutil
ImportError: No module named psutil

UPDATE

launching pip install psutil i got this:

Requirement already satisfied (use --upgrade to upgrade): psutil in /usr/local/lib/python2.7/site-packages

Any ideas on how to resolve this error?

Upvotes: 1

Views: 20446

Answers (2)

Ben Mares
Ben Mares

Reputation: 2157

In case you are using Debian or a derivative like Ubuntu, if you are trying to install psutil then pip is unnecessary.

There is a system package called python3-psutil which can be installed with

sudo apt-get install python3-psutil

This should allow all users on your system to reliably import psutil from python3.

Upvotes: 0

MK.
MK.

Reputation: 34587

https://github.com/giampaolo/psutil/blob/master/INSTALL.rst

Installing using pip on UNIX

The easiest way to install psutil on UNIX is by using pip (but first you might need to install python header files; see later). First install pip:

$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py

...then run:

$ pip install psutil

You may need to install gcc and python header files first (see later).

Upvotes: 5

Related Questions