Python rpyc cannot run psutil command remotely

I am trying to run a command psutil

remotely:

import os, sys, time
import rpyc
import psutil

command = """def rpcexecute():
       import psutil
       cpu = psutil.cpu_percent(interval=1)
       return cpu"""

conn = rpyc.classic.connect('192.168.0.100')
conn.execute(command)
remote_exec = conn.namespace['rpcexecute']
result = remote_exec()

      

I have error: "ImportError: No module named psutil"

but I installed psutil

in both (remote and local).

When I test with, for example, with import os

, it works great.

What advice?

Thank.

+3


source to share


1 answer


Resolved!

I have restarted the classic rpyc service on the server and try again. It works fine now.



BR,

Junix

+2


source







All Articles