【问题标题】:how to succesfully compile python 3.x如何成功编译python 3.x
【发布时间】:2020-01-22 16:13:31
【问题描述】:

在尝试编译 python 3.7 时,我点击了Could not import runpy module

jeremyr@b88:$ wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
....
jeremyr@b88:~/Python-3.7.3$ ./configure --enable-optimizations    
jeremyr@b88:~/Python-3.7.3$ make clean 
jeremyr@b88:~/Python-3.7.3$ make -j32 
.... 

gcc -pthread     -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.7m.a -lcrypt -lpthread -ldl  -lutil   -lm  
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
    echo "generate-posix-vars failed" ; \
    rm -f ./pybuilddir.txt ; \
    exit 1 ; \
fi
Could not import runpy module
Traceback (most recent call last):
  File "/home/jeremyr/Python-3.7.3/Lib/runpy.py", line 15, in <module>
    import importlib.util
  File "/home/jeremyr/Python-3.7.3/Lib/importlib/util.py", line 14, in <module>
    from contextlib import contextmanager
  File "/home/jeremyr/Python-3.7.3/Lib/contextlib.py", line 4, in <module>
    import _collections_abc
SystemError: <built-in function compile> returned NULL without setting an error
generate-posix-vars failed
Makefile:603: recipe for target 'pybuilddir.txt' failed
make[1]: *** [pybuilddir.txt] Error 1
make[1]: Leaving directory '/home/jeremyr/Python-3.7.3'
Makefile:531: recipe for target 'profile-opt' failed
make: *** [profile-opt] Error 2

jeremyr@88:~/Python-3.7.3$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.11 (jessie)
Release:    8.11
Codename:   jessie

jeremyr@88:~/Python-3.7.3$ gcc --version 
gcc (Debian 4.9.2-10+deb8u2) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

jeremyr@88:~/Python-3.7.3$ sudo apt upgrade gcc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... gcc is already the newest version.

jeremyr@b88:~/Python-3.7.3$ echo $PYTHONPATH

任何关于如何克服这个问题并安装 python3.7 的建议表示赞赏。

编辑 - 下面列出的解决方案似乎适用于各种其他 python 版本,所以我将标题从 3.7 更改为 python 3.x

【问题讨论】:

  • 你找到解决方案了吗?
  • iirc 当我取出 --enable-optimizations 时 runpy 错误被克服,然后又出现一个错误,然后成功。
  • ahhh 好的,我最终发现我们的 gcc 也已过时,但我在该系统上找到了一个旧的 python3 副本,它似乎可以与我试图开始工作的 aws-cli 一起使用。 (我们的python2无法处理新的签名v4)
  • 这是宇宙 11.3 的吗?
  • 宇宙 11.3 是什么?

标签: python gcc compiler-errors python-3.7 runpy


【解决方案1】:

似乎启用优化是问题所在,

jeremyr@b88:~/Python-3.7.3$ ./configure   
jeremyr@b88:~/Python-3.7.3$ make clean 

在我的情况下会处理它。

【讨论】:

  • 谢谢,我只是在编译 Python 3.5.9 时遇到了这个问题。
  • 我刚刚在 python3.8.5 & centos7 和 gcc 4.8.3 中遇到了这个问题。在我的情况下这个修复!谢谢,@jeremy_ruthan
  • 这里相同 - 这工作(没有 enable-optimizations)编译本地/独立 Python 3.8.3
猜你喜欢
  • 2020-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多