Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: error importing smtplib

Thread Tools

Re: error importing smtplib

Terry Reedy
Posts: n/a
On 11/16/2012 2:37 PM, Eric Frederich wrote:
> So I inspected the process through /proc/<pid>/maps
> That seemed to show what libraries had been loaded (though there is
> probably an easier way to do this).

> In any case, I found that if I import smtplib before logging in I see
> these get loaded...
> /opt/foo/python27/lib/python2.7/lib-dynload/
> /lib64/
> Then after logging in, I see this other .so get loaded...
> /opt/bar/lib64/

That version appears to be about a decade old. Why is bar using it?

> So that is what happens when when things are well and I don't get any
> error messages.
> However, when I do the log in first I see the /opt/bar .so file loaded first
> /opt/bar/lib64/
> Then after importing smtplib I see the other two show up...
> /opt/foo/python27/lib/python2.7/lib-dynload/
> /lib64/

What I know is that imports _hashlib (compilied .c) and that
the latter wraps libssl, or calls which wraps libssl. In *nix
this is expected to already be on the system, so in not distributed with
python. Furthermore, hashlib requires a version recent enough to have
the latest (best) hash functions. I suspect decade-old 9.9.7 does not

What I don't know is how .so loading and linking works. It seems that
two version get loaded but linking gets messed up. This reminds me of
'dll hell' on Windows . I don't know either if modifying the loading
of ...9.7 in for or bar code could do anything.

> So.... I'm guessing the problem is that after I log in, the process has
> a conflicting file loaded.
> Then when I try to import smtplib it tries getting things from there and
> that is where the errors are coming from.
> The question now is how do I fix this?

[easy] Do the import before the function call, which is the proper order
and the one that works.

Remove ...9.7 from bar/lib64/ and have bar use the up-to-date system
version, like python does. An alternative is to replace ...9.7 with a
duplicate ...9.8e (and probably better, only load it if there is no
system version).

> What else should I be checking?

Thinking more, you can look at sys.modules, but this does not have any
info about non-module libraries wrapped by modules, even if the latter
are C-coded.

Terry Jan Reedy

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: error importing smtplib Dieter Maurer Python 0 11-18-2012 07:06 AM
Re: error importing smtplib Dieter Maurer Python 0 11-16-2012 07:38 PM
Re: error importing smtplib Terry Reedy Python 0 11-15-2012 09:37 PM
Re: error importing smtplib Terry Reedy Python 0 11-15-2012 04:57 PM
[SMTPLIB] how to send a "Multiline" mail with smtplib? Evan Python 3 06-23-2008 08:50 AM