|
操作环境:CentOS7、Gcc4.8.5、Python3.10.0系统上已经有2.x,3.6版本的Python了,但是还是想装一个3.10的。因为刚写的脚本文件是较高版本的,在3.6上无法正常运行,Python语法不是很了解,只能从环境上下手了。【注】Python其他版本也适用,毕竟是编译器的问题,并非Python版本问题。下载源码文件,然后开始执行操作:./configure--enable-optimizationsmakesudomakeinstall123然后报错如下,下面是两个机器不同的报错:#报错一:gcc-pthread-Xlinker-export-dynamic-opythonPrograms/python.olibpython3.10.a-lcrypt-lpthread-ldl-lutil-lm-lm./python-E-S-msysconfig--generate-posix-vars;\iftest$?-ne0;then\ echo"generate-posix-varsfailed";\ rm-f./pybuilddir.txt;\ exit1;\fiCouldnotimportrunpymoduleTraceback(mostrecentcalllast):File"/opt/Python-3.10.0/Lib/runpy.py",line15,inimportimportlib.utilFile"/opt/Python-3.10.0/Lib/importlib/util.py",line14,infromcontextlibimportcontextmanagerFile"/opt/Python-3.10.0/Lib/contextlib.py",line4,inimport_collections_abcSystemError:returnedNULLwithoutsettinganexceptiongenerate-posix-varsfailedmake:***[pybuilddir.txt]Error112345678910111213141516171819#报错二:makebuild_allCFLAGS_NODIST="-fprofile-use-fprofile-correction"LDFLAGS_NODIST=""make[1]:Enteringdirectory`/usr/local/src/Python-3.10.0'./python-E-S-msysconfig--generate-posix-vars;\iftest$?-ne0;then\ echo"generate-posix-varsfailed";\ rm-f./pybuilddir.txt;\ exit1;\fiCouldnotimportrunpymoduleTraceback(mostrecentcalllast):File"/opt/Python-3.10.0/Lib/runpy.py",line15,inimportimportlib.utilFile"/opt/Python-3.10.0/Lib/importlib/util.py",line14,infromcontextlibimportcontextmanagerFile"/opt/Python-3.10.0/Lib/contextlib.py",line4,inimport_collections_abcSystemError:returnedNULLwithoutsettinganerrorgenerate-posix-varsfailedmake[1]:***[pybuilddir.txt]Error1make[1]eavingdirectory`/opt/Python-3.10.0'make:***[profile-opt]Error212345678910111213141516171819202122导致原因在低版本的gcc版本,使用gcc命令并带有--enable-optimizations参数时会出现上面问题。在gcc8.1.0此问题已经修复。解决方法1、升级gcc至8.1.0,不是很推荐,可能会影响其他软件的编译。2、./configure参数中去掉--enable-optimizations。然后执行下面的命令:./configuremakesudomakeinstall123如果还不行就将解压的Python目录删除掉,重新解压,然后重新执行上面的命令。Python镇楼!!!点下关注好不好,我想申请博客专家!!!哭唧唧!!!个人博客:Roc’sBlog
|
|