Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError. undefined symbol: prlimit #442

Closed
giampaolo opened this issue May 23, 2014 · 20 comments
Closed

ImportError. undefined symbol: prlimit #442

giampaolo opened this issue May 23, 2014 · 20 comments

Comments

@giampaolo
Copy link
Owner

From shchepyo...@gmail.com on October 17, 2013 20:07:47

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: http://code.google.com/p/psutil/issues/detail?id=442

@giampaolo
Copy link
Owner Author

From g.rodola on October 19, 2013 01:20:26

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?)?

Labels: OpSys-Linux

@giampaolo
Copy link
Owner Author

From shchepyo...@gmail.com on October 19, 2013 10:00:13

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.

Attachment: install.txt

@giampaolo
Copy link
Owner Author

From g.rodola on October 19, 2013 10:38:19

Please try revision 5bdae7b71188 .

@giampaolo
Copy link
Owner Author

From shchepyo...@gmail.com on October 19, 2013 12:14:12

Thank you! Revision 5bdae7b71188 working on my server.

@giampaolo
Copy link
Owner Author

From D.V.Selitsky@gmail.com on October 22, 2013 10:32:50

Dear Giampaolo,
Please release v1.1.2.

@giampaolo
Copy link
Owner Author

From g.rodola on October 22, 2013 11:17:52

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!). =)

Status: Fixed
Labels: Milestone-1.1.2

@giampaolo
Copy link
Owner Author

From Web...@gmail.com on October 26, 2013 13:33:30

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"

@giampaolo
Copy link
Owner Author

From g.rodola on October 27, 2013 02:12:27

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

Status: ReOpened

@giampaolo
Copy link
Owner Author

From Web...@gmail.com on October 27, 2013 09:44:05

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...

@giampaolo
Copy link
Owner Author

From Web...@gmail.com on October 27, 2013 10:20:42

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.

@giampaolo
Copy link
Owner Author

From DanaGoye...@gmail.com on November 04, 2013 15:16:39

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,

@giampaolo
Copy link
Owner Author

From g.rodola on November 06, 2013 09:09:32

Please anyone try revision af484b3ac7a5 .

Labels: -Priority-Medium -Milestone-1.1.2 Priority-High

@giampaolo
Copy link
Owner Author

From g.rodola on November 06, 2013 11:07:17

Sorry, try revision c3c9aae2d70b which hopefully should fix this issue once and for all.

@giampaolo
Copy link
Owner Author

From DanaGoye...@gmail.com on November 06, 2013 12:52:01

Thanks, that does seem to work -- now the module loads properly in my container 
environment.

@giampaolo
Copy link
Owner Author

From g.rodola on November 06, 2013 13:30:45

Finally! I will see if I can pack up a new version tomorrow.

@giampaolo
Copy link
Owner Author

From g.rodola on November 07, 2013 13:25:47

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. =)

Status: Fixed
Labels: Milestone-1.1.3

@jhaoheng
Copy link

jhaoheng commented Oct 2, 2018

Hi

I got this issue
ImportError: /bin/psutil._psutil_linux.so: undefined symbol: prlimit64

  • python 2.7.10
  • liunx 6
  • psutil 5.4.7

@giampaolo
Copy link
Owner Author

What Linux distro do you have?

@giampaolo giampaolo reopened this Oct 9, 2018
@jhaoheng
Copy link

jhaoheng commented Oct 9, 2018

Hi @giampaolo

I use 0.1.2 and the issue solved.

The newer version need 'Linux >= 2.6.36 (supposedly) and glibc >= 13'
but linux 6 support glibc below 11

thank you so much.

@giampaolo
Copy link
Owner Author

I believe I fixed this some time ago. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants