不知何故,我的 ext3 文件系统的一部分被损坏了,我的 python 安装的大部分都被搞乱了。我能立即注意到的唯一一件事是 Python 引发了一个缺少模块的错误。如果我尝试 cd 到相关目录,我会得到以下信息:
EXT3-fs error (device mmcblk0p2): htree_dirblock_to_tree: bad entry in directory #444159: directory entry across blocks - offset=0, inode=166100, rec_len=59284, name_len=255
EXT3-fs error (device mmcblk0p2): htree_dirblock_to_tree: bad entry in directory #444137: rec_len % 4 != 0 - offset=0, inode=290535, rec_len=39605, name_len=253
所以我决定只 rm -rf 这些目录并重新安装 NumPy。没那么快:
root@napajohn:/usr/lib/pyshared/python2.6/numpy-1.6.0# python setup.py
Running from numpy source directory.Traceback (most recent call last):
File "setup.py", line 196, in <module>
setup_package()
File "setup.py", line 173, in setup_package
from numpy.distutils.core import setup
File "/usr/lib/pyshared/python2.6/numpy-1.6.0/numpy/distutils/__init__.py", line 7, in <module>
import ccompiler
File "/usr/lib/pyshared/python2.6/numpy-1.6.0/numpy/distutils/ccompiler.py", line 7, in <module>
from distutils.ccompiler import *
File "/usr/lib/python2.6/distutils/__init__.py", line 1
d__2);
^
SyntaxError: invalid syntax
那个错误说的是真的。文件 /usr/lib/python2.6/distutils/__init__.py 开始中间表达式,就好像文件的上半部分被切掉一样。
所以我去检查一下是否安装了任何其他版本的 Python pyversions -i
:
File "/usr/lib/python2.6/ConfigParser.py", line 1
.i,
^
SyntaxError: invalid syntax
我的所有文件发生了什么?我意识到如果没有额外的信息就很难回答这个问题,但在我走这条路之前,让我将上下文切换到我的第一个替代解决方案,该解决方案天真地假设除了 python 之外没有其他任何东西受到影响。
首先,有一个问题:安装附加软件(或者更具体地说,Python)的“正确”位置在哪里?我一直选择 /opt 来解压和安装我不通过 apt 下载的东西。
接下来,问题:
root@napajohn:/opt/python/Python-2.7.3# ./configure
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking machine type as reported by uname -m... armv7l
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/opt/python/Python-2.7.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
我没有gcc??好吧,不管怎样,我去安装一下。我运行更新然后
root@napajohn:/opt/python/Python-2.7.3# apt-get install gcc-4.4
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:
gcc-4.4 : Depends: gcc-4.4-base (= 4.4.5-8) but 4.4.5-8em1 is to be installed
Depends: cpp-4.4 (= 4.4.5-8) but 4.4.5-8em1 is to be installed
Recommends: libc6-dev (>= 2.5) but it is not going to be installed
E: Broken packages
但我有 gcc-4.4-base 和 cpp-4.4!
root@napajohn:/opt/python/Python-2.7.3# apt-get install gcc-4.4-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-4.4-base is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
root@napajohn:/opt/python/Python-2.7.3# apt-get install cpp-4.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
cpp-4.4 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
经过一些搜索后,我认为这可能是由于版本不匹配(术语?)引起的。
我不太确定从这里该去哪里。还有一个更大的问题是文件问题是否与 Python 无关。我应该fsck
对 rootfs 运行磁盘检查吗?我该如何在嵌入式设备上执行此操作?
root@napajohn:/opt/python/Python-2.7.3# cat /etc/debian_version
6.0.4
root@napajohn:/opt/python/Python-2.7.3# df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 250876 0 250876 0% /lib/init/rw
udev 10240 156 10084 2% /dev
tmpfs 250876 0 250876 0% /dev/shm
rootfs 7597856 1722208 5489688 24% /