[Python-bugs-list] [ python-Bugs-565710 ] ImportError: No module named _socket

noreply@sourceforge.net noreply@sourceforge.net
Thu, 26 Sep 2002 21:47:03 -0700


Bugs item #565710, was opened at 2002-06-07 04:38
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=565710&group_id=5470

Category: None
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 6
Submitted By: Philipp Kolmann (pkolmann)
Assigned to: Guido van Rossum (gvanrossum)
Summary: ImportError: No module named _socket

Initial Comment:
Hi,

I just wanted to try out Mailman on a Sun Solaris
machine and compiled therefore Python 2.2.

It did compile ok, but there seems to be a problem with
the socket library:

bash-2.03$ python /opt/PYthon/lib/python2.2/socket.py
Traceback (most recent call last):
  File "/opt/PYthon/lib/python2.2/socket.py", line 41, in ?
    from _socket import *
ImportError: No module named _socket


Could you help me with this problem.

Thanks a lot
Philipp Kolmann

----------------------------------------------------------------------

>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-09-27 00:47

Message:
Logged In: YES 
user_id=12800

BTW, this is a duplicate of 551353, which is currently
closed (and I'm keeping it closed since we don't need two
open bugs on the same issue).

However, in 551353 Martin outlines some approaches that a
user can take so that the .so files are properly found at
runtime.  I must disagree that Python can't do better.  We
hashed out a similar issue with the bsddb library which
installs in /usr/local/BerkeleyDB.X.Y by default, also not
on the default ld search path.  In that case we agreed to
add the setup.py magic to compile in the runtime path to the
library, and I think we should do the same with the ssl library.

setup.py already finds the dynamic libraries so it can just
as easily add the -R flag.  Too many people get bit by this
problem and there are basically no diagnostics to help
someone figure out what needs to be done to fix the problem.
 In 551353, Martin says that sometimes adding -R isn't
right, but I think for most people it will be right.  For
those that adding -R does the wrong thing, they can hack the
code, and I believe that adding -R will make life better for
the majority of users.

I assigned this to Guido for pronouncement.

----------------------------------------------------------------------

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-09-27 00:35

Message:
Logged In: YES 
user_id=12800

This is an ld.so problem.  I can reproduce this on the SF
compile farm's Solaris8/Sparc box.  Python 2.2's brain
damaged dynlib build procedure removes any .so it can't
import, which makes it very difficult to tell what the
problem is, if it's not evident in the compilation output.  

In this particular case, rebuilding _socket.so by hand, and
then importing it clearly shows that the dynamic linker
can't find libssl.so.xxx and libcrypto.so.xxx.  On this
Solaris box, these libraries reside in /usr/local/ssl/lib
but that's not on the default ld.so search path and the
build script doesn't use the -R option to compile in the
location of those libraries.

The fix is to add "runtime_library_dirs = ssl_libs," to the
Extension constructor for socketmodule.c in the top level
setup.py.  I've tested this with Python 2.2 maint, but I'll
bet it'll hit Python 2.3 too.

Attached is a patch that ought to fix the problem for
Solaris.  It appears to do no harm on Linux.  Under the same
rationale we came up with for the bsddb module, I think this
should be added, otherwise the socket module will just plain
be busted for (some? all? most?) Solaris systems.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-06-11 05:14

Message:
Logged In: YES 
user_id=6656

But the usual reason for the _socket module not to build on
solaris is ssl issues.  Without more info it's hard to say
anything more (hint, hint, Philipp).

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-06-10 15:30

Message:
Logged In: YES 
user_id=6380

MWH: I don't see the connection with SSL. More likely
somehow the socket module didn't get built. Quite possibly
his whole installation is hosed. Reducing the priority since
local configuration errors are usually not something that
Python can do anything about.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-06-07 09:33

Message:
Logged In: YES 
user_id=6656

The problem is probably ssl support.  Try editing
Modules/Setup and uncommenting the line:

#_socket socketmodule.c

If you *need* ssl support, then you'll have to dig deeper...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=565710&group_id=5470