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?
Advertisement
Answer
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).