This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: make install error: ImportError: No module named _struct
Type: compile error Stage: resolved
Components: Installation Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: chay, iritkatriel, ned.deily, suzhengchun
Priority: normal Keywords:

Created on 2012-06-14 14:36 by suzhengchun, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg162794 - (view) Author: suzhengchun (suzhengchun) Date: 2012-06-14 14:36
if test -d /WORK/suzc/installed/python/lib/python2.7/distutils/tests; then \
        /usr/bin/install -c -m 644 ./Modules/xxmodule.c \
                /WORK/suzc/installed/python/lib/python2.7/distutils/tests ; \
fi
PYTHONPATH=/WORK/suzc/installed/python/lib/python2.7   \
        ./python -Wi -tt /WORK/suzc/installed/python/lib/python2.7/compileall.py \
        -d /WORK/suzc/installed/python/lib/python2.7 -f \
        -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
        /WORK/suzc/installed/python/lib/python2.7
Traceback (most recent call last):
  File "/WORK/suzc/installed/python/lib/python2.7/compileall.py", line 16, in <module>
    import struct
  File "/WORK/suzc/installed/python/lib/python2.7/struct.py", line 1, in <module>
    from _struct import *
ImportError: No module named _struct
make: *** [libinstall] 错误 1            


In directory /WORK/suzc/software/Python-2.7.3, I do this:
suzc@linux-opensuse:22:33:28:Python-2.7.3$ ./configure --prefix=/WORK/suzc/installed/python --exec-prefix=/WORK/suzc/installed/python --mandir=/WORK/suzc/installed/man | tee -a config_make.20120614.log
make 
make install

and then meets the install error!!

python's version is 2.7.3, i download the .tgz & .bz2, both the some problem.


My system is:
suzc@linux-opensuse:22:33:28:Python-2.7.3$ uname -a
Linux linux-opensuse 3.1.0-rc7-3-desktop #1 SMP PREEMPT Wed Sep 28 14:41:36 UTC 2011 (50fb02f) x86_64 x86_64 x86_64 GNU/Linux
suzc@linux-opensuse:22:35:22:Python-2.7.3$ lsb_release -a
LSB Version:    n/a
Distributor ID: SUSE LINUX
Description:    openSUSE 12.1 Beta 1 (x86_64)
Release:        12.1
Codename:       Asparagus


any help? Thank you very much.
msg162839 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-06-15 02:38
I have no experience with opensuse but, from a general unix install install view, the most obvious cause of that message would be a build failure of the _struct extension.  Check the log file for messages with _struct in it.  You could also try to check the paths and to import it in the build directory:

PYTHONPATH=/WORK/suzc/installed/python/lib/python2.7 \
 ./python -c 'import sys; print(sys.paths)'
PYTHONPATH=/WORK/suzc/installed/python/lib/python2.7 \
 ./python -c 'import _struct; print(_struct.__file__)'
msg162904 - (view) Author: suzhengchun (suzhengchun) Date: 2012-06-15 14:40
Thank for your attention.

I try it:
suzc@linux-opensuse:22:02:51:Python-2.7.3$ PYTHONPATH=/WORK/suzc/installed/python/lib/python2.7 ./python -c 'import sys; print(sys.path)'
['', '/WORK/suzc/installed/python/lib/python2.7', '/WORK/suzc/installed/python/lib/python27.zip', '/WORK/suzc/installed/python/lib/python2.7/plat-linux2', '/WORK/suzc/installed/python/lib/python2.7/lib-tk', '/WORK/suzc/installed/python/lib/python2.7/lib-old', '/WORK/suzc/installed/python/lib/python2.7/lib-dynload', '/WORK/suzc/.local/lib/python2.7/site-packages', '/WORK/suzc/installed/python/lib/python2.7/site-packages']
suzc@linux-opensuse:22:03:03:Python-2.7.3$ PYTHONPATH=/WORK/suzc/installed/python/lib/python2.7 \
> ./python -c 'import _struct; print(_struct.__file__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named _struct                                           1
suzc@linux-opensuse:22:03:23:Python-2.7.3$



And I read the log of make, it seems to be compiled OK:
-----------------------------------------------------------------
ranlib libpython2.7.a
gcc -pthread  -Xlinker -export-dynamic -o python \
        Modules/python.o \
        libpython2.7.a -lpthread -ldl  -lutil   -lm
running build
running build_ext
building dbm using ndbm
building '_struct' extension
gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/local/include -I/WORK/suzc/software/Python-2.7.3/Include -I/WORK/suzc/software/Python-2.7.3 -c /WORK/suzc/software/Python-2.7.3/Modules/_struct.c -o build/temp.linux-x86_64-2.7/WORK/suzc/software/Python-2.7.3/Modules/_struct.o
gcc -pthread -shared build/temp.linux-x86_64-2.7/WORK/suzc/software/Python-2.7.3/Modules/_struct.o -L/WORK/suzc/installed/python/lib64 -L/usr/local/lib -o build/lib.linux-x86_64-2.7/_struct.so
building '_ctypes_test' extension
-----------------------------------------------------------------

_struct.o and _struct.so are just there, I truely don't know what's wrong.
Newly to Python, I think python should not have such an installation problem.



I installed it(2.7.3) on RHEL5, works OK, but I want to install OpenSSL to it, don't know how to do it, so I learn to install it on SUSE in my workplace while RHEL5 is in another place. 

RHEL5 has python 2.4.2, in my memory. SUSE12 has python 2.7.2.

Does system's python affect my installtion? But I think it shouldn't.



In fact, long before I downloaded a compressed package named Python-2.7.3.tar.bz2, with this one, I can make && make install, but I can't run it, error is:

suzc@linux-opensuse:22:12:31:bin$ ./python2.7
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
  File "/WORK/suzc/installed/python/lib/python2.7/site.py", line 564, in <module                                                                                        >
    main()
  File "/WORK/suzc/installed/python/lib/python2.7/site.py", line 546, in main
    known_paths = addusersitepackages(known_paths)
  File "/WORK/suzc/installed/python/lib/python2.7/site.py", line 279, in adduser                                                                                        sitepackages
    user_site = getusersitepackages()
  File "/WORK/suzc/installed/python/lib/python2.7/site.py", line 254, in getuser                                                                                        sitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/WORK/suzc/installed/python/lib/python2.7/site.py", line 244, in getuser                                                                                        base
    USER_BASE = get_config_var('userbase')
  File "/WORK/suzc/installed/python/lib/python2.7/sysconfig.py", line 521, in ge                                                                                        t_config_var
    return get_config_vars().get(name)
  File "/WORK/suzc/installed/python/lib/python2.7/sysconfig.py", line 420, in ge                                                                                        t_config_vars
    _init_posix(_CONFIG_VARS)
  File "/WORK/suzc/installed/python/lib/python2.7/sysconfig.py", line 288, in _i                                                                                        nit_posix
    raise IOError(msg)
IOError: invalid Python installation: unable to open /WORK/suzc/installed/python                                                                                        /lib/python2.7/config/Makefile (No such file or directory)   

I'm crazy about this, I search it in google, no satisfatory answers. So I want to download a new one 2.7.3, and install, but i just can not install it.

Thanks again.
msg173795 - (view) Author: Antonio Chay (chay) Date: 2012-10-25 19:38
Hello there!
I have the same issue, using CentOS 5.8, I *reversed* this patch:

http://bugs.python.org/issue8205

and now "make install" works.

A side note: before it failed to compile _multiprocessing, with the patch reversed now is included.

HTH.
Regards!
msg396038 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-18 10:07
Lib/site.py has changed a lot in the meantime compared to the patch that Antonio mentioned.

Unless you are currently seeing this issue with 3.9+ I suggest we close this and let a new issue be opened if someone does see this problem on a current version.
History
Date User Action Args
2022-04-11 14:57:31adminsetgithub: 59271
2021-06-25 22:28:57iritkatrielsetstatus: pending -> closed
stage: resolved
2021-06-18 10:07:22iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg396038

resolution: out of date
2012-10-25 19:38:33chaysetnosy: + chay
messages: + msg173795
2012-06-15 14:40:48suzhengchunsetmessages: + msg162904
2012-06-15 02:38:11ned.deilysetnosy: + ned.deily
messages: + msg162839
2012-06-14 14:36:22suzhengchuncreate