Ubuntu16.04:错误的 lsb_release 文件

Ubuntu16.04:错误的 lsb_release 文件

我有一台虚拟机:操作系统:Ubuntu 16.04.1 LTS 内核:Linux 4.4.0-59-generic 架构:x86-64

本系统中,python 有两个版本:2.7.12 和 3.5。还安装了 Pip。Pip 版本为:

pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

每次pip install <package>运行时都会出错。主要错误是因为lsb_release -a返回了错误。我lsb_release -a从控制台运行,然后出现无效语法错误:

File "/usr/bin/lsb_release", line 64
print("No LSB modules are available.", file=sys.stderr)
                                           ^

lsb_release文件的头部有以下内容:

#!/usr/bin/python3 -Es

但是系统似乎不知道如何到达 python3,尽管使用以下命令将 python3 的符号链接设置为 python3.5:

sudo ln -s /usr/bin/python3.5 /usr/bin/python3

命令的输出ls -l /usr/bin/python*如下:

lrwxrwxrwx 1 root root       9 Dec  9  2015 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root       9 Dec  9  2015 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3546104 Nov 19 01:35 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Nov 19 01:35 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Dec  9  2015 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 Jan 26 09:07 /usr/bin/python3 -> python3.5
-rwxr-xr-x 2 root root 3546104 Jan 19 14:23 /usr/bin/python3.5
lrwxrwxrwx 1 root root      33 Nov 17 11:23 /usr/bin/python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 3546104 Jan 19 14:23 /usr/bin/python3.5m
lrwxrwxrwx 1 root root      34 Nov 17 11:23 /usr/bin/python3.5m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx 1 root root      16 Mar 23  2016 /usr/bin/python3-config -> python3.5-config
lrwxrwxrwx 1 root root      10 Jun  6  2016 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root      17 Mar 23  2016 /usr/bin/python3m-config -> python3.5m-config
lrwxrwxrwx 1 root root      16 Dec  9  2015 /usr/bin/python-config -> python2.7-config

检查的版本python3.5,我得到了 2.7 版本:

$ /usr/bin/python3.5 --version
Python 2.7.12

当我执行时,系统显示有些不对劲 ll -a /usr/share/man/man1 | grep python。输出为:

-rw-r--r--  1 root root   3367 Dec  9  2015 dh_python2.1.gz
-rw-r--r--  1 root root   3280 May 18  2016 dh_python3.1.gz
lrwxrwxrwx  1 root root     14 Dec  9  2015 python.1.gz -> python2.7.1.gz
lrwxrwxrwx  1 root root     14 Dec  9  2015 python2.1.gz -> python2.7.1.gz
-rw-r--r--  1 root root   5640 Nov 19 01:32 python2.7.1.gz
lrwxrwxrwx  1 root root     38 Nov 19 01:35 python2.7-config.1.gz -> x86_64-linux-gnu-python2.7-config.1.gz
lrwxrwxrwx  1 root root     21 Dec  9  2015 python2-config.1.gz -> python2.7-config.1.gz
lrwxrwxrwx  1 root root     14 Jun  6  2016 python3.1.gz -> python3.5.1.gz
-rw-r--r--  1 root root   5174 Nov 17 10:43 python3.5.1.gz
lrwxrwxrwx  1 root root     38 Nov 17 11:23 python3.5-config.1.gz -> x86_64-linux-gnu-python3.5-config.1.gz
lrwxrwxrwx  1 root root     14 Nov 17 11:23 python3.5m.1.gz -> python3.5.1.gz
lrwxrwxrwx  1 root root     39 Nov 17 11:23 python3.5m-config.1.gz -> x86_64-linux-gnu-python3.5m-config.1.gz
lrwxrwxrwx  1 root root     21 Mar 23  2016 python3-config.1.gz -> python3.5-config.1.gz
lrwxrwxrwx  1 root root     15 Jun  6  2016 python3m.1.gz -> python3.5m.1.gz
lrwxrwxrwx  1 root root     22 Mar 23  2016 python3m-config.1.gz -> python3.5m-config.1.gz
lrwxrwxrwx  1 root root     21 Dec  9  2015 python-config.1.gz -> python2.7-config.1.gz
-rw-r--r--  1 root root    921 Nov 19 00:15 x86_64-linux-gnu-python2.7-config.1.gz
lrwxrwxrwx  1 root root     39 Nov 17 11:23 x86_64-linux-gnu-python3.5-config.1.gz -> x86_64-linux-gnu-python3.5m-config.1.gz
-rw-r--r--  1 root root    907 Nov 23  2013 x86_64-linux-gnu-python3.5m-config.1.gz
lrwxrwxrwx  1 root root     38 Mar 23  2016 x86_64-linux-gnu-python3-config.1.gz -> x86_64-linux-gnu-python3.5-config.1.gz
lrwxrwxrwx  1 root root     39 Mar 23  2016 x86_64-linux-gnu-python3m-config.1.gz -> x86_64-linux-gnu-python3.5m-config.1.gz
lrwxrwxrwx  1 root root     38 Dec  9  2015 x86_64-linux-gnu-python-config.1.gz -> x86_64-linux-gnu-python2.7-config.1.gz

3.5 软件包x86_64-linux-gnu-python3.5-config.1.gz有一个指向 3.5m 的符号链接。这很奇怪吗?

现在的问题是如何将 python3 指向正确的版本。有办法吗?

谢谢

答案1

您只需清除 lsb-release 包并再次安装即可解决您的问题。

 $ sudo apt purge lsb-release
 $ sudo apt install lsb-release 

答案2

问题是 Python 版本 2.7.12 和 3.5.2 在虚拟机上出现了问题。一个快速的解决方案就是清除虚拟机并创建另一个。这解决了我的问题。

相关内容