在ubuntu18.04上为ARM交叉编译python2.7时缺少模块

2024-07-03 05:56:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我遵循了名为“Cross-compiling Python”的堆栈交换帖子中的指令。步骤非常简单,python在目标上运行。你知道吗

但是,当我尝试在目标上创建virtualenv时,它会抱怨缺少“\u struct”模块。在redditImportError: 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,然后是cross python。同样的问题仍然存在。你知道吗

最近有没有人在ubuntu18.04x86\u64主机上交叉编译过python2.7版本?具体步骤是什么?你知道吗

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


Tags: 模块no目标forvirtualenv堆栈on指令
1条回答
网友
1楼 · 发布于 2024-07-03 05:56:56

不确定这是否是正确的解决方案。我尝试将内容添加到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

相关问题 更多 >