giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.37k forks source link

[Linux] cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) #2419

Closed mattthhh closed 1 month ago

mattthhh commented 1 month ago

Summary

Description

Hi, when I try to import the the lib that I cloned to modules/libs/ with these lines :

sys.path.insert(0, "modules/libs/")
import psutil

I got this error : ImportError: cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import)

Any ideas ? (I don't want to use pip or venv to get the library, because it needs to be flexible)

giampaolo commented 1 month ago

psutil is not a pure python module, it needs to be compiled, so you can't get away with sys.path.insert.

mattthhh commented 1 month ago

Okay, do you have any ideas to import this lib without pip and venv ? Maybe compile it from the source code ?

mattthhh commented 1 month ago

Okay I found, just compile it locally with a simple python interpreter, and add the result of the compilation in sys.path