1

i want to get memory information like (total, free and used). But i should use python own library. Not with psutil or smth.

I'm on Mac and using 2.7 python.

For example when i tried ;

import sys
if sys.platform == 'win32':
  import win32_sysinfo as sysinfo
elif sys.platform == 'darwin':
  import mac_sysinfo as sysinfo
elif 'linux' in sys.platform:
  import linux_sysinfo as sysinfo

print 'Memory available:', sysinfo.memory_available()

i get;

Traceback (most recent call last):
  File "/Users/Elfendos/Documents/Phyton/deneme.py", line 5, in <module>
    import mac_sysinfo as sysinfo
ImportError: No module named mac_sysinfo
zedfoxus
  • 35,121
  • 5
  • 64
  • 63
  • http://stackoverflow.com/questions/276052/how-to-get-current-cpu-and-ram-usage-in-python, http://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python, http://stackoverflow.com/questions/466684/how-can-i-return-system-information-in-python might help you. – zedfoxus Oct 14 '15 at 19:51
  • Could you please post the code you tried and the output you received? – zedfoxus Oct 14 '15 at 20:24
  • I tried linkes but doesnt work. Even i tried them with empty .py file. – Hakan Görgülü Oct 14 '15 at 20:29
  • Edit your question and post the code along with the error. Make sure you use the formatting tools above the editing textbox to ensure your code looks readable. Include whether you are working on Windows, OSX or Linux and also indicate the version of python on your system. Doesn't work gives me very little to work with. – zedfoxus Oct 14 '15 at 20:32
  • Good edit. I don't have OSX handy. This might be worth a try: http://stackoverflow.com/questions/467600/how-can-i-read-system-information-in-python-on-os-x and this http://fa.bianp.net/blog/2013/different-ways-to-get-memory-consumption-or-lessons-learned-from-memory_profiler/. Please do post back a solution that worked for you. – zedfoxus Oct 14 '15 at 20:42
  • I tried but cannot get print .i just want to get print memory info :) but non of links give me point. how can we solve it – Hakan Görgülü Oct 14 '15 at 20:53
  • Unfortunately I won't be able to assist without Mac. Hopefully someone else with a Mac might chip in. – zedfoxus Oct 14 '15 at 20:53
  • can we use https://docs.python.org/3.5/library/resource.html – Hakan Görgülü Oct 14 '15 at 20:56

0 Answers0