【问题标题】:Cross-compiling Python 2.7 for ARM on Ubuntu 18.04 with Missing Modules在缺少模块的 Ubuntu 18.04 上为 ARM 交叉编译 Python 2.7
【发布时间】:2019-12-22 01:07:39
【问题描述】:

我按照标题为“Cross-compiling Python”的堆栈交换帖子中的说明进行操作。这些步骤很简单,python 在目标上运行。

但是,当我尝试在目标上创建 virtualenv 时,它会抱怨缺少“_struct”模块。在 reddit ImportError: No module named _struct on cross compiled Python for ARM7 和 python.org Issue28444 Missing extensions modules when cross compiling python 3.5.2 for arm on Linux 上搜索出现了类似的问题。我跟着讨论,先编译了原生python,然后是交叉python。同样的问题仍然存在。

最近有人在 Ubuntu 18.04 x86_64 主机上交叉编译了 python 2.7 版本吗?步骤的确切顺序是什么?

顺便说一句,我知道之前在 stackoverflow 网站上的其他帖子,例如cross-compiling Python 2.7.4+ 和其他一些帖子。那些可能太过时了。我还遇到了一个示例Modules/Setup.local,如果按原样使用会出现很多错误。

【问题讨论】:

    标签: python python-2.7 cross-compiling


    【解决方案1】:

    不确定这是否是正确的解决方案。我通过向Modules/Setup.local 添加内容进行了实验。添加_struct 行后,原来的错误就消失了。最终使用如下文件:

    # 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
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-23
    • 1970-01-01
    • 2014-05-01
    • 1970-01-01
    相关资源
    最近更新 更多