繁体   English   中英

安装2.7.5时出现段错误

[英]Segfault when installing 2.7.5

我正在使用相对较干净的Ubuntu 18.10。 我试图开始使用pyenv,我设法用它来安装python 3.7.2。

但是,我尝试的第二件事是安装2.7.5,无论我如何尝试,安装都会失败。

$ pyenv install 2.7.5
Downloading Python-2.7.5.tgz...
-> https://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
Installing Python-2.7.5...
patching file ./Modules/readline.c
Hunk #1 succeeded at 204 (offset -2 lines).
Hunk #2 succeeded at 747 (offset -2 lines).
Hunk #3 succeeded at 857 (offset -2 lines).
Hunk #4 succeeded at 905 (offset -13 lines).
patching file ./Lib/site.py
patching file ./Lib/ssl.py
Hunk #2 succeeded at 430 (offset -5 lines).
patching file ./Modules/_ssl.c
Hunk #1 succeeded at 65 (offset -2 lines).
Hunk #2 succeeded at 304 (offset -4 lines).
Hunk #3 succeeded at 1729 (offset -83 lines).

BUILD FAILED (Ubuntu 18.10 using python-build 1.2.9-12-g99092d7f)

Inspect or clean up the working tree at /tmp/python-build.20190219134616.5823
Results logged to /tmp/python-build.20190219134616.5823.log

Last 10 log lines:
        Modules/python.o \
        libpython2.7.a -lpthread -ldl  -lutil   -lm  
/usr/bin/ld: libpython2.7.a(posixmodule.o): in function `posix_tmpnam':
/tmp/python-build.20190219134616.5823/Python-2.7.5/./Modules/posixmodule.c:7515: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/bin/ld: libpython2.7.a(posixmodule.o): in function `posix_tempnam':
/tmp/python-build.20190219134616.5823/Python-2.7.5/./Modules/posixmodule.c:7462: warning: the use of `tempnam' is dangerous, better use `mkstemp'
./python -E -S -m sysconfig --generate-posix-vars
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
make: *** [Makefile:464: pybuilddir.txt] Segmentation fault (core dumped)

出于好奇,我尝试了一个全新安装的干净VM,并得到了相同的错误,但是在正式的Docker映像上,它确实起作用了。 因此,关于我的环境肯定有一些错误。

但是呢

Python 2.7.5无法使用gcc-8 Ubuntu 8.2.0-7ubuntu1编译器正确构建,这是Ubuntu 18.10的默认编译器。

解决此问题的最简单方法是安装gcc 7.3.0并符号链接到/usr/bin/gcc

在这个问题的答案downgrade-gnu-compilers-ubuntu-18-04中有很好的描述。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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