天哪,我今天真是过得很漫长。就像大多数使用 Linux 的日子一样,一开始很有趣,但后来变得很搞笑。
我差不多花了一整天时间重新安装一个基本的 Gnome Ubuntu 系统。一切都很顺利,直到我开始安装 XBMC 部分。经过几个小时与 PPA 和 apt-get 的较量,我终于安装好了,但很快一切都变得很尴尬。
它就是无法启动。我点击了图标,几秒钟内什么都没发生。然后屏幕闪烁了一下黑色,但之后什么都没有了。我从终端启动,它显示一条错误消息,说无法导入 Python 的 os 和shutil 模块。我觉得这很奇怪,因为这两个模块都是 Python 标准库的一部分。
最后,奇怪的是,结果似乎不是 XBMC 的问题,突然 apt-get 也开始抱怨了。
TL,DR:我(或系统)无法在 Ubuntu 中导入 Python 中的任何标准库模块!救命!
这是路径问题吗?或者我实际上是否设法卸载了一些重要的 Python 包,如果是的话,卸载哪些包?
如果这很重要的话,我正在运行 Ubuntu 10.10。
编辑:我想我已经弄清楚了问题所在。我不小心将 fstab 中的一行拆分成两行。有问题的行是根目录,所以我猜是错误的挂载(它就在标志部分被拆分)导致系统到处创建坏块。经过一番艰苦的战斗,我设法修复了 python 问题(我只是将 /usr/lib 中的零碎部分从正常运行的 10.10 系统复制到坏系统,python 突然又恢复了活力)。但我无法找出我遇到的初始错误,即启动 xbmc 时出现段错误。然后今天我碰巧随机打开了 fstab 文件,在那里我更正了拆分行,之后 xbmc 又可以正常工作了。呼。我现在要去睡觉了。
这里有一些显示错误消息的转储:(我忘了复制 XBMC 错误消息,但它看起来与下面的完全相同,即它无法导入 os 模块)
首先从 apt-get:
tv@tv:/usr/lib$ sudo apt-get autoremove
[sudo] password for tv:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libqt3-mt python-qt3 python-sip
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 19.2MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 75111 files and directories currently installed.)
Removing python-qt3 ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/sbin/update-python-modules", line 11, in <module>
import sys,os,shutil
ImportError: No module named os
dpkg: error processing python-qt3 (--remove):
subprocess installed pre-removal script returned error exit status 1
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/sbin/update-python-modules", line 11, in <module>
import sys,os,shutil
ImportError: No module named os
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 1
Removing python-sip ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "/usr/sbin/update-python-modules", line 11, in <module>
import sys,os,shutil
ImportError: No module named os
dpkg: error processing python-sip (--remove):
subprocess installed pre-removal script returned error exit status 1
Removing libqt3-mt ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
python-qt3
python-sip
E: Sub-process /usr/bin/dpkg returned an error code (1)
tv@tv:/usr/lib$
其次尝试在终端的常规 Python 提示符中导入 os 模块:
tv@tv:~$ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named os
>>>