Ubuntu 12.04 安装 Python 3.3 的问题

Ubuntu 12.04 安装 Python 3.3 的问题

最初我从源代码安装了 Python 3.3,但后来我删除了目录/usr/lib/python3.3

当我使用 aptitude 安装它时,出现此错误。

Unpacking python3.3 (from .../python3.3_3.3.1-1ubuntu5_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils ...
Setting up python3.3 (3.3.1-1ubuntu5) ...
python3.3: can't open file '/usr/lib/python3.3/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing python3.3 (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 python3.3
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install.  Trying to recover:
Setting up python3.3 (3.3.1-1ubuntu5) ...
python3.3: can't open file '/usr/lib/python3.3/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing python3.3 (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:

知道如何纠正这个错误吗?

答案1

您已libpython3.3-minimal在删除过程中破坏了该软件包。请重新安装它,然后尝试python3.3再次安装。如果您安装了依赖于 的其他软件包libpython3.3-minimal,则可能也需要重新安装它们。

注意:下次手动安装的软件应放入/usr/local/opt,而不要/usr直接放入 。这可避免手动安装的文件和软件包发生冲突,因为所有软件包都安装到/usr

答案2

要安装 python 版本 3.3.2,请按照以下步骤操作,并且成功了

wget http://python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2

tar -xvjf ./Python-3.3.2.tar.bz2

cd ./Python-3.3.2

./configure --prefix=/opt/python3.3

make && make install

mkdir ~/bin

ln -s /opt/python3.3/bin/python ~/bin/py

echo 'alias py="/opt/python3.3/bin/python3"' >> .bashrc

答案3

由于您已经“破坏”了 Python 安装的某些部分(正如 Jan Hudec 指出的那样),因此安装 python3.3 会失败,因为dpkg系统认为其他软件包仍然存在。检查受您的操作影响的软件包:

# dpkg -S /usr/lib/python3.3/
python3-gdbm:i386, python3.3, libpython3.3-minimal:i386, libpython3.3-stdlib:i386, libpython3.3:i386: /usr/lib/python3.3

并明确重新安装提供该目录下文件的所有软件包。这将确保该文件/usr/lib/python3.3/py_compile.py和其他文件pre-depends在安装过程中在正确的时间出现任何受您的操作影响的文件都会得到修复。

注意:上述命令的输出可能会有所不同,请相应地调整以下内容。

# aptitude reinstall python3-gdbm python3.3 libpython3.3-minimal libpython3.3-stdlib libpython3.3

相关内容