简体   繁体   中英

Cross-compiling Python 2.7 for ARM on Ubuntu 18.04 with Missing Modules

I followed the instruction from a stack-exchange post titled " Cross-compiling Python ". The steps have been straightforward and the python runs on the target.

However, when I'm trying to create a virtualenv on target, it complains about the "_struct" module missing. A search turned up a similar question on reddit ImportError: No module named _struct on cross compiled Python for ARM7 , and on python.org Issue28444 Missing extensions modules when cross compiling python 3.5.2 for arm on Linux . I followed the discussions, Compiled a native python first, then the cross python. The same issue still exists.

Has anybody recently cross-compiled python 2.7 versions on a Ubuntu 18.04 x86_64 host? What's the exact sequence of steps?

By the way, I'm aware of other posts earlier on the stackoverflow site, eg cross-compiling Python 2.7.4+ , and a few other posts. Those probably are too dated. I also came across a sample Modules/Setup.local , that got a lot of errors if just use as is.

Not sure whether this is the right solution. I experimented by adding content to the Modules/Setup.local . After adding the _struct line, the original error went away. Eventually using a file like:

# Edit this file for local setup changes

#*shared*

#readline readline.c -lreadline -ltermcap


# Modules that should always be present (non UNIX dependent):

array arraymodule.c    # array objects
cmath cmathmodule.c _math.c # -lm # complex math library functions
math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
_struct _struct.c      # binary structure packing/unpacking
time timemodule.c # -lm # time operations and variables
operator operator.c    # operator.add() and similar goodies
#_testcapi _testcapimodule.c    # Python C API test module
_random _randommodule.c        # Random number generator
_collections _collectionsmodule.c # Container types
_heapq _heapqmodule.c          # Heapq type
itertools itertoolsmodule.c    # Functions creating iterators for efficient looping
strop stropmodule.c            # String manipulations
_functools _functoolsmodule.c  # Tools for working with functions and callable objects
_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
#_pickle _pickle.c      # pickle accelerator
datetime datetimemodule.c      # date/time type
_bisect _bisectmodule.c        # Bisection algorithms

unicodedata unicodedata.c    # static Unicode character database

# access to ISO C locale support
#_locale _localemodule.c  # -lintl

# Standard I/O baseline
_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c


# added due to missing for virtualenv:
binascii binascii.c
cStringIO cStringIO.c
cPickle cPickle.c


# Modules with some UNIX dependencies -- on by default:

fcntl fcntlmodule.c    # fcntl(2) and ioctl(2)
spwd spwdmodule.c              # spwd(3)
grp grpmodule.c                # grp(3)
select selectmodule.c  # select(2); not on ancient System V

# Memory-mapped files (also works on Win32).
mmap mmapmodule.c

# CSV file helper
_csv _csv.c

# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c


# Some more UNIX dependent modules -- off by default, since these
# are not supported by all UNIX systems:

#nis nismodule.c -lnsl  # Sun yellow pages -- not everywhere
termios termios.c      # Steen Lumholt's termios module
resource resource.c    # Jeremy Hylton's rlimit interface


# Note that the _md5 and _sha modules are normally only built if the
# system does not have the OpenSSL libs containing an optimized version.

# The _md5 module implements the RSA Data Security, Inc. MD5
# Message-Digest Algorithm, described in RFC 1321.  The necessary files
# md5.c and md5.h are included here.

_md5 md5module.c md5.c


# The _sha module implements the SHA checksum algorithms.
# (NIST's Secure Hash Algorithms.)
_sha shamodule.c
_sha256 sha256module.c
_sha512 sha512module.c


# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM