jucapj / psutil

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

ImportError. undefined symbol: prlimit #442

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi!
Sorry for my English.
I installed with the help of let pip. In the console do import psutil and get 
an error.

>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/psutil/__init__.py", line 89, in <module>
    import psutil._pslinux as _psplatform
  File "/usr/local/lib/python2.6/dist-packages/psutil/_pslinux.py", line 21, in <module>
    import _psutil_linux
ImportError: /usr/local/lib/python2.6/dist-packages/_psutil_linux.so: undefined 
symbol: prlimit

What version of psutil are you using? What Python version?
psutil-1.1.1
Python 2.6.6

On what operating system?

OS: Debian GNU/Linux 6.0
Uname: Linux 3.2.0-0.bpo.4-amd64 #1 SMP Debian 3.2.41-2+deb7u2~bpo60+1 x86_64 
GNU/Linux

Original issue reported on code.google.com by shchepyo...@gmail.com on 17 Oct 2013 at 6:07

GoogleCodeExporter commented 8 years ago
Mmmm. I though I fixed this in issue 438.
Are you sure this is 1.1.1 version and not 1.1.0?
Please paste the output of "grep -r prlimit /usr/include/".
Also, does "man prlimit" work (I mean is the manual available?)?

Original comment by g.rodola on 19 Oct 2013 at 8:20

GoogleCodeExporter commented 8 years ago
1. In the file "install.txt" output installing via pip. Install the version 
1.1.1
2. The command "grep -r prlimit /usr/include/" no output
3. The command "man prlimit" outputs "No manual entry for prlimit"

P.S.
On another server I have is OS Debian 6.0. But the kernel Linux 2.6.32-5-amd64 
# 1 SMP Mon Feb 25 02:37:03 UTC 2013 x86_64 GNU/Linux. There psutil runs great.
This server, paragraphs 2 and 3 have the same result.

Original comment by shchepyo...@gmail.com on 19 Oct 2013 at 5:00

Attachments:

GoogleCodeExporter commented 8 years ago
Please try revision 5bdae7b71188.

Original comment by g.rodola on 19 Oct 2013 at 5:38

GoogleCodeExporter commented 8 years ago
Thank you!
Revision 5bdae7b71188 working on my server.

Original comment by shchepyo...@gmail.com on 19 Oct 2013 at 7:14

GoogleCodeExporter commented 8 years ago
Dear Giampaolo,
Please release v1.1.2.

Original comment by D.V.Selitsky@gmail.com on 22 Oct 2013 at 5:32

GoogleCodeExporter commented 8 years ago
I released a 1.1.2 bugfix-only release just now:
https://pypi.python.org/pypi/psutil#downloads
I really hope this issue won't appear again (this is the second time in 2 
releases!). =)

Original comment by g.rodola on 22 Oct 2013 at 6:17

GoogleCodeExporter commented 8 years ago
Hello!
I use Linux Debian 6.0, kernel 3.1.0-1.2-xen and psutil-1.1.2 (latest version). 
Unfortunately I have the same error =(

"uname -a": Linux vmName 3.1.0-1.2-xen #5 SMP i686 GNU/Linux
---------------------
Python 3.3.0 (default, Oct 26 2013, 23:51:51)                                   
[GCC 4.7.2] on linux                                                            
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 89, in <module>                             
    import psutil._pslinux as _psplatform                                       
  File "./psutil/_pslinux.py", line 21, in <module>                             
    import _psutil_linux                                                        
ImportError: 
/usr/local/myProjectName/python/lib/python3.3/site-packages/_psutil_li
nux.cpython-33m.so: undefined symbol: prlimit  
------------------

1) command:
cat 
/usr/local/myProjectName/python/lib/python3.3/site-packages/psutil/__init__.py 
| grep __version__
display: __version__ = "1.1.2"

2) command: "grep -r prlimit /usr/include/" no output
3) command: "man prlimit" outputs "No manual entry for prlimit"

Original comment by Web...@gmail.com on 26 Oct 2013 at 8:33

GoogleCodeExporter commented 8 years ago
Damn!
How is that even possible?
In _psutil_linux.c we check whether __NR_prlimit64 is defined.
Your grep into /usr/include clearly shows it isn't so it should assume 
prlimit() is NOT available.
Are you sure this is not a problem of 'old installation files still sticking 
around'?
Please retry like this:

cd psutil-1.1.2
rm -rf build dist
sudo rm -rf  /usr/local/myProjectName/python/lib/python3.3/site-packages/psutil*
python setup.py install

Original comment by g.rodola on 27 Oct 2013 at 9:12

GoogleCodeExporter commented 8 years ago
Hello!

First of all, I am sorry "grep -r prlimit /usr/include/" command output: 
/usr/include/asm-generic/unistd.h:#define __NR_prlimit64 261                    
/usr/include/asm-generic/unistd.h:__SYSCALL(__NR_prlimit64, sys_prlimit64)      
/usr/include/asm/unistd_x32.h:#define __NR_prlimit64 (__X32_SYSCALL_BIT + 302)  
/usr/include/asm/unistd_64.h:#define __NR_prlimit64 302                         
/usr/include/asm/unistd_32.h:#define __NR_prlimit64 340   

I have made a small research.
I type next commands: (tmp - it is an empty folder)

cd /tmp
wget http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
tar jxf ./Python-3.3.0.tar.bz2
cd ./Python-3.3.0
./configure  --prefix=/tmp/python
make
make install

/tmp/python/bin/python3.3 and enter: import psutil. It is output: "ImportError: 
no module named 'psuitl'"

cd /tmp/python/lib/python3.3/site-packages, than I enter "ls" command.
this command say that this directory contains only README file.

Than I type:
cd /tmp
wget https://pypi.python.org/packages/source/p/psutil/psutil-1.1.2.tar.gz
tar -zxvf psutil-1.1.2.tar.gz
cd psutil-1.1.2
/tmp/python/bin/python3.3 setup.py install

output:
----------------------------
    .................
byte-compiling /tmp/python/lib/python3.3/site-packages/psutil/_compat.py to _com
pat.cpython-33.pyc                                                              
byte-compiling /tmp/python/lib/python3.3/site-packages/psutil/_pssunos.py to _ps
sunos.cpython-33.pyc                                                            
byte-compiling /tmp/python/lib/python3.3/site-packages/psutil/_error.py to _erro
r.cpython-33.pyc                                                                
running install_egg_info                                                        
Writing /tmp/python/lib/python3.3/site-packages/psutil-1.1.2-py3.3.egg-info
-----------------------------------

/tmp/python/bin/python3.3 and enter: import psutil
output:
------------------------------------
Traceback (most recent call last):                                              
  File "<stdin>", line 1, in <module>                                           
  File "./psutil/__init__.py", line 89, in <module>                             
    import psutil._pslinux as _psplatform                                       
  File "./psutil/_pslinux.py", line 21, in <module>                             
    import _psutil_linux                                                        
ImportError: /tmp/python/lib/python3.3/site-packages/_psutil_linux.cpython-33m.s
o: undefined symbol: prlimit
-----------------------------------
In the file "/tmp/psutil-1.1.2/psutil/_psutil_linux.c" I changed "#define 
HAVE_PRLIMIT defined(PSUTIL_KERN_PRLIMIT) && defined(__NR_prlimit64)"
to "#define HAVE_PRLIMIT 0" and after that all work fine.

---
I have moved "#define HAVE_PRLIMIT defined(PSUTIL_KERN_PRLIMIT) && 
defined(__NR_prlimit64)" at the top of the file (_psutil_linux.c) and it is 
still equal true. There are not any "#includes" before this line.

After all of this, I have write small C programm:
#define HAVE_PRLIMIT defined(__NR_prlimit64)
int main(int argc, char *argv[]) {                                              

#if HAVE_PRLIMIT                                                                
    printf ("yes");                                                                 
#else                                                                           
    printf ("no");                                                                  
#endif                                                                          
        return 0;                                                               
}  
after compilation it is print "no", so I can not understand, why when I compile 
psuitl "defined(__NR_prlimit64)" is true (and this causes the error), but when 
I complie my test program "defined(__NR_prlimit64)" is false...

Original comment by Web...@gmail.com on 27 Oct 2013 at 4:44

GoogleCodeExporter commented 8 years ago
At this link: http://bugs.python.org/issue16595 I have found that "prlimit() 
needs glibc 2.13+". But command "ldd --version" return: "ldd (Debian EGLIBC 
2.11.3-4) 2.11.3", so may be this causes an error.

Original comment by Web...@gmail.com on 27 Oct 2013 at 5:20

GoogleCodeExporter commented 8 years ago
I'm using CentOS 6.4 in an lxc container under an Ubuntu 13.04 host.  

It seems like checking for __NR_prlimit64 must not be entirely correct, since 
I'm still getting the import error even with the above revision.

Kernel version: 3.11.0-12-generic (containers use the host's kernel)

Guest glibc:
ldd (GNU libc) 2.12

Guest grep:
/usr/include/asm-generic/unistd.h:#define __NR_prlimit64 261
/usr/include/asm-generic/unistd.h:__SYSCALL(__NR_prlimit64, sys_ni_syscall)
/usr/include/asm/unistd_64.h:#define __NR_prlimit64             302
/usr/include/asm/unistd_64.h:__SYSCALL(__NR_prlimit64, sys_ni_syscall)
/usr/include/asm/unistd_32.h:/* #define __NR_prlimit64      340 */
/usr/include/bits/syscall.h:#define SYS_prlimit64 __NR_prlimit64

Host glibc:
ldd (Ubuntu EGLIBC 2.17-93ubuntu4) 2.17

Host grep:
/usr/include/asm-generic/unistd.h:#define __NR_prlimit64 261
/usr/include/asm-generic/unistd.h:__SYSCALL(__NR_prlimit64, sys_prlimit64)
/usr/include/x86_64-linux-gnu/asm/unistd_x32.h:#define __NR_prlimit64 
(__X32_SYSCALL_BIT + 302)
/usr/include/x86_64-linux-gnu/asm/unistd_64.h:#define __NR_prlimit64 302
/usr/include/x86_64-linux-gnu/asm/unistd_32.h:#define __NR_prlimit64 340
/usr/include/x86_64-linux-gnu/bits/syscall.h:#define SYS_prlimit64 
__NR_prlimit64
/usr/include/x86_64-linux-gnu/bits/syscall.h:#define SYS_prlimit64 
__NR_prlimit64
/usr/include/x86_64-linux-gnu/bits/syscall.h:#define SYS_prlimit64 
__NR_prlimit64
/usr/include/x86_64-linux-gnu/bits/resource.h:extern int prlimit (__pid_t 
__pid, enum __rlimit_resource __resource,
/usr/include/x86_64-linux-gnu/bits/resource.h:extern int __REDIRECT_NTH 
(prlimit, (__pid_t __pid,
/usr/include/x86_64-linux-gnu/bits/resource.h:                   struct rlimit 
*__old_limit), prlimit64);
/usr/include/x86_64-linux-gnu/bits/resource.h:#   define prlimit prlimit64
/usr/include/x86_64-linux-gnu/bits/resource.h:extern int prlimit64 (__pid_t 
__pid, enum __rlimit_resource __resource,

Original comment by DanaGoye...@gmail.com on 4 Nov 2013 at 11:16

GoogleCodeExporter commented 8 years ago
Please anyone try revision af484b3ac7a5.

Original comment by g.rodola on 6 Nov 2013 at 5:09

GoogleCodeExporter commented 8 years ago
Sorry, try revision c3c9aae2d70b which hopefully should fix this issue once and 
for all.

Original comment by g.rodola on 6 Nov 2013 at 7:07

GoogleCodeExporter commented 8 years ago
Thanks, that does seem to work -- now the module loads properly in my container 
environment.

Original comment by DanaGoye...@gmail.com on 6 Nov 2013 at 8:52

GoogleCodeExporter commented 8 years ago
Finally! I will see if I can pack up a new version tomorrow.

Original comment by g.rodola on 6 Nov 2013 at 9:30

GoogleCodeExporter commented 8 years ago
New 1.1.3 version is out.
Closing this out for now and seriously: I hope I won't have to reopen this for 
the fourth time. =) 

Original comment by g.rodola on 7 Nov 2013 at 9:25

GoogleCodeExporter commented 8 years ago
I am facing same issue on MAC.

xymMac-vikash_kumar$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named psutil
>>> 

Original comment by vikash2c...@gmail.com on 10 Nov 2014 at 9:52

GoogleCodeExporter commented 8 years ago
You cannot have this issue on OSX because:
- it should have already been fixed
- (most importantly) it's not supposed to happen on OSX at all because the 
functionality using prlimit() is Linux only (!)
That error means psutil is not installed for some reason.

Original comment by g.rodola on 10 Nov 2014 at 10:08

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks g.rodola. It looks like psutil is not installed properly. I tried to 
reinstall ... facing some error.

<<
SymMacToolkit-CPWKWBL7DTY3:/ vikash_kumar$ pip install psutil
Downloading/unpacking psutil
  Downloading psutil-2.1.3.tar.gz (224kB): 224kB downloaded
  Running setup.py egg_info for package psutil

    warning: no previously-included files matching '*' found under directory 'docs/_build'
Installing collected packages: psutil
  Running setup.py install for psutil
    building '_psutil_osx' extension
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c psutil/_psutil_osx.c -o build/temp.macosx-10.8-intel-2.7/psutil/_psutil_osx.o
    clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
    clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
    error: command 'clang' failed with exit status 1
    Complete output from command /usr/bin/python -c "import 
>>

So will eliminate this issue 1st. 

Original comment by vikash2c...@gmail.com on 12 Nov 2014 at 8:55