在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: 

知道如何纠正错误吗?

你已经删除了那个删除中的libpython3.3-minimal包。 重新安装它,而不是再次尝试安装python3.3 。 如果您安装了依赖于libpython3.3-minimal其他软件包,则可能还需要重新安装它们。

注意:下次手动安装的软件应该放在/usr/local/opt ,永远不要放在/usr/local 这避免了手动安装的文件和包之间的冲突,因为所有包都安装到/usr

要安装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 

因为你已经’销毁’部分你的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