peter-hst / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Can't import psutil #313

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Install psutil 0.5.1 from source (on Linux)
2. python setup.py install
3. >>> import psutil

What is the expected output?
psutil should be imported

What do you see instead?
michal@cdn-controller:~/psutil-0.5.1$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "psutil/__init__.py", line 94, in <module>
    TOTAL_PHYMEM = _psplatform.phymem_usage()[0]
  File "psutil/_pslinux.py", line 140, in phymem_usage
    cached = cached_phymem()
  File "psutil/_pslinux.py", line 121, in cached_phymem
    raise RuntimeError("line not found")
RuntimeError: line not found
>>> 

What version of psutil are you using? What Python version?
psutil 0.5.1
python 2.6.6

On what operating system? Is it 32bit or 64bit version?
Debian 6.0 (Squeeze), 64b, kernel 2.6.32-5-openvz-amd64
I'm running virtualized Linux inside OpenVZ.

Please provide any additional information below.
_pslinux.py tries to read "Cached:" in /proc/meminfo, but there is no such line 
in my file:
cat /proc/meminfo
MemTotal:        4194304 kB
MemFree:         3757852 kB
SwapTotal:             0 kB
SwapFree:              0 kB

Original issue reported on code.google.com by michal.s...@gmail.com on 1 Aug 2012 at 1:07

GoogleCodeExporter commented 8 years ago
Could you please try latest SVN version?
I've been doing a lot of work against memory-related stuff lately so the issue 
at hand might already have been fixed by my changes.

Original comment by g.rodola on 1 Aug 2012 at 1:11

GoogleCodeExporter commented 8 years ago
SVN version seems to work properly, thanks!

Original comment by michal.s...@gmail.com on 1 Aug 2012 at 1:25

GoogleCodeExporter commented 8 years ago
However I got another similar problem (with a SVN version of psutil):

>>> psutil.phymem_usage()
__main__:1: DeprecationWarning: psutil.phymem_usage is deprecated
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/psutil/_common.py", line 101, in inner
    return fun(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/psutil/__init__.py", line 1063, in phymem_usage
    mem = virtual_memory()
  File "/usr/lib/pymodules/python2.6/psutil/__init__.py", line 946, in virtual_memory
    return _psplatform.virtual_memory()
  File "/usr/lib/pymodules/python2.6/psutil/_pslinux.py", line 139, in virtual_memory
    raise RuntimeError("line(s) not found")
RuntimeError: line(s) not found

Original comment by michal.s...@gmail.com on 2 Aug 2012 at 11:55

GoogleCodeExporter commented 8 years ago
Heh... that's controversial as I'm not sure what's best to do: fill the missing 
fields with a null (0) value or let the exception propagate. 

> cat /proc/meminfo
> MemTotal:        4194304 kB
> MemFree:         3757852 kB
> SwapTotal:             0 kB
> SwapFree:              0 kB

Is this the whole file content produced on Debian Squeeze? If not can you paste 
the complete output?

Original comment by g.rodola on 6 Aug 2012 at 5:37

GoogleCodeExporter commented 8 years ago
Yes, unfortunatelly it is. But I don't think it's a Debian issue, but an OpenVZ 
issue. It simply does not include all necessary info:

root@cdn-controller:~# uname -a
Linux cdn-controller.dev 2.6.32-5-openvz-amd64 #1 SMP Tue Jun 14 10:46:15 UTC 
2011 x86_64 GNU/Linux
root@cdn-controller:~# cat /proc/meminfo 
MemTotal:        4194304 kB
MemFree:         2943512 kB
SwapTotal:             0 kB
SwapFree:              0 kB
root@cdn-controller:~# 

Original comment by michal.s...@gmail.com on 7 Aug 2012 at 12:27

GoogleCodeExporter commented 8 years ago
I suppose that's not the only missing piece of information.
Have you tried to run tests?
I expect other failures due to file contents of /proc fs being incomplete or 
missing.
In that case I think we better off considering OpenVZ an unsupported platform.
I already have enough work on my hands with the other four *major* platforms 
(and another fifth one on the way =)).

Original comment by g.rodola on 9 Aug 2012 at 9:11

GoogleCodeExporter commented 8 years ago
I modified both virtual_memory() and swap_memory() so that they no longer raise 
an exception in case of missing values not found in /proc fs.
Instead, the missing values are now set to 0 and a RuntimeWarning is raised.
Done in r1534.

Original comment by g.rodola on 17 Aug 2012 at 6:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Updated csets after the SVN -> Mercurial migration:
r266 == revision f910f2f333cc
r1534 == revision 29c612ebf39d

Original comment by g.rodola on 2 Mar 2013 at 12:11

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 5 Mar 2013 at 12:16

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 8 Apr 2013 at 1:21

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 11 Apr 2013 at 9:17

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 12 Apr 2013 at 6:21