奇怪的 Python 版本行为

奇怪的 Python 版本行为

我有一个较旧的 Ubuntu/Linux Mint 版本,其中 apt 中最新的 Python 是 2.7.6。我对该版本有些问题,因此我从源代码构建了 2.7.14。但是一旦我离开终端,Python 就会报告错误的版本。

我构建并安装 Python 的终端:

python
Python 2.7.14 (default, Aug 14 2018, 13:40:31)
[GCC 6.4.0 20180424] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/local/bin/python'

构建后启动第二个终端

python
Python 2.7.6 (default, Nov 23 2017, 15:53:45)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/local/bin/python'

更糟糕的是实际构建的二进制文件。我构建的终端:

/usr/local/lib/python2.7.14/bin/python2.7
Python 2.7.14 (default, Aug 14 2018, 13:40:31)
[GCC 6.4.0 20180424] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/local/lib/python2.7.14/bin/python2.7'

第二航站楼:

/usr/local/lib/python2.7.14/bin/python2.7
Python 2.7.6 (default, Nov 23 2017, 15:53:45)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/local/lib/python2.7.14/bin/python2.7'

相关内容