ERROR: ImportError: No module named 'psutil'

Поиск
Список
Период
Сортировка
От Ganesh Korde
Тема ERROR: ImportError: No module named 'psutil'
Дата
Msg-id CAPNyb0X=vq55ZWNuK1n+gfhPLy+J8KDn9XXcONKj30iZPYi+Kw@mail.gmail.com
обсуждение исходный текст
Ответы Re: ERROR: ImportError: No module named 'psutil'  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Hi Everyone,

Environment
OS : Linux ubuntu 4.4.0-87-generic
Database:  PostgreSQL 10.7 on x86_64-pc-linux-gnu,
Extension: plpython3u
Python version: Python 3.5.2

 I am trying to run a python function using the language plpython3u and I am getting the below error, though I have installed psutil.

postgres=# select * from get_psutil_mem();
ERROR:  ImportError: No module named 'psutil'
CONTEXT:  Traceback (most recent call last):
  PL/Python function "get_psutil_mem", line 2, in <module>
    from psutil import virtual_memory, swap_memory
PL/Python function "get_psutil_mem"

 Below is the successful execution of psutil

root@ubuntu:~# python
Python 3.5.2 (default, Jan 26 2021, 13:30:48)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.cpu_times()
scputimes(user=139677.25, nice=755.4, system=53408.11, idle=10956992.84, iowait=18110.06, irq=0.0, softirq=1294.34, steal=0.0, guest=0.0, guest_nice=0.0)
>>>

Function details:

CREATE OR REPLACE FUNCTION get_psutil_mem(
OUT total float8, OUT used float8, OUT free float8, OUT buff_cache float8, OUT available float8, OUT percent float8,
OUT swap_total float8, OUT swap_used float8, OUT swap_free float8, OUT swap_percent float8
)
 LANGUAGE plpython3u
AS $FUNCTION$
from psutil import virtual_memory, swap_memory
vm = virtual_memory()
sw = swap_memory()
return vm.total, vm.used, vm.free, vm.buffers + vm.cached, vm.available, vm.percent, sw.total, sw.used, sw.free, sw.percent
$FUNCTION$;

The above function is used by pgwatch2 to monitor memory.

I tried installing python3.4.3 from source code but still the same error. Also tried most of the solutions provided on the internet but nothing helped. Problem is with the psutil module only.

Please let me know if I am missing anything.

Any help will be much appreciated. 

Regards,
Ganesh Korde.

В списке pgsql-general по дате отправления:

Предыдущее
От: Vijaykumar Jain
Дата:
Сообщение: Re: postgres vacuum memory limits
Следующее
От: Tom Lane
Дата:
Сообщение: Re: postgres vacuum memory limits