运行 Ubuntu 18.04 并想尝试运行 FSLint 来清除一些空间,但遇到了问题......
$ fslint-gui
Traceback (most recent call last):
File "/usr/bin/fslint-gui", line 27, in <module>
import gtk
ImportError: No module named gtk
我查了一下,有一个建议
$ pip install pygtk
Collecting pygtk
Using cached https://files.pythonhosted.org/packages/7c/18/fa4f2de77500dd62a314fd845ff6e903ac2ce551164cb421c5750969f799/pygtk-2.24.0.tar.bz2
Complete output from command python setup.py egg_info:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file. *
********************************************************************
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zgzLmi/pygtk/
当那失败时我尝试了apt
。
$ sudo apt install --install-recommends python-gtk2
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-gtk2 is already the newest version (2.24.0-5.1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
然后我想也许模块隐藏在dev
。
$ sudo apt install --install-recommends python-gtk2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-gtk2-dev : Depends: libgtk2.0-dev (>= 2.18.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
好吧,我顺着依赖关系线索往下走,却走进了死胡同。
$ sudo apt install python-gtk2-dev libgtk2.0-dev libpango1.0-dev libcairo2-dev libfontconfig1-dev libxft-dev libfontconfig1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libfontconfig1 is already the newest version (2.12.6-0ubuntu2.3).
libfontconfig1 set to manually installed.
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
或已移出接收状态。以下信息可能有助于解决此情况:
The following packages have unmet dependencies:
libfontconfig1-dev : Depends: libfontconfig1 (= 2.12.6-0ubuntu2) but 2.12.6-0ubuntu2.3 is to be installed
E: Unable to correct problems, you have held broken packages.
您认为该如何解决这个问题?
附加信息
不久前我用简单的安装了它sudo apt install fslint
。
我按照 N0rbert 的说法运行了以下命令:
$ sudo apt-get install fslint libglade2-0 python-cairo python-glade2 python-gobject-2 python-gtk2
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-cairo is already the newest version (1.16.2-1).
fslint is already the newest version (2.44-4ubuntu1).
libglade2-0 is already the newest version (1:2.6.4-2).
python-glade2 is already the newest version (2.24.0-5.1ubuntu2).
python-gobject-2 is already the newest version (2.28.6-12ubuntu3).
python-gtk2 is already the newest version (2.24.0-5.1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
which python
给我/usr/local/bin/python
只需输入即可python
打开
Python 2.6.6 (r266:84292, Nov 20 2019, 15:47:02)
[GCC 7.4.0] on linux4
我甚至尝试了purge
和,install
但fslint
没有任何依赖项被重新安装。我甚至sudo apt install -f
没有成功。
darksky 的其他更新
Python 2.6.6
。那可能是你的问题。默认的 python 2 应该是 2.7。你可以尝试一下sudo apt install python2
,确保运行 时它是 2.7python2
,然后fslint-gui
再次运行吗?
$ sudo apt install python2
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python2
$ sudo apt install python2[TAB]
python2.7 python2.7-doc python2-pyro4
python2.7-dbg python2.7-examples python2-selectors34
python2.7-dev python2.7-minimal python2-serpent
$ sudo apt install python2.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.7 is already the newest version (2.7.15-4ubuntu4~18.04.2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
python2.7-dev is already the newest version (2.7.15-4ubuntu4~18.04.2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
事实上,你的 python 就在那里
/usr/local/bin
,没有/usr/bin
告诉我你或其他人已经手动安装了它,可能是从源代码安装的。
我认为我没有进行过源代码构建。make
这通常会导致缺少依赖项。首次安装系统时是否已预装 python?也许我应该从备份操作系统安装(16.04)中复制一些文件。
另外,通过运行 sudo update-alternatives --config python 确保将您的 python 指向 python2,并确保它指向 python2 或 python2.7,而不是 2.6 的任何内容。
$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python
答案1
18.04 发行版的默认 Python 2 版本始终是 2.7。如果你只是sudo apt install python
在 18.04 中运行,你最终会得到一个/usr/bin
软链接到的Python 2.7 /usr/bin/python2.7
。你有不知何故在您的系统中安装了 python2.6 /usr/local
,它似乎优先于 2.7。您需要做的第一件事是确保 2.7 再次成为默认值。
一个简单的方法是将您的重命名/usr/local/bin/python
为/usr/local/bin/python2.6
。如果有 ,/usr/local/bin/python2
您可能也想将其删除。最后,当您这样做时,您which python
应该会看到/usr/bin/python
。如果您运行,ll /usr/bin/python
您应该会看到/usr/bin/python -> python2.7*
。您还可以python2
通过创建sudo ln -s /usr/bin/python2.7 /usr/bin/python2
以进一步兼容需要python2
特定程序的程序。
Python 是操作系统的重要组成部分,并且很多依赖它的软件包,包括程序fslint
。因此,如果您的系统范围的 Python 不是 18.04 通常附带的,您可能会遇到奇怪的依赖问题。
最后,您不需要-dev
python 的版本,因为您没有编译任何依赖于源代码中的 python 头文件的东西。