【问题标题】:apt-get remove python by accidentapt-get 意外删除 python
【发布时间】:2016-04-20 19:02:16
【问题描述】:

更新:是的,这是一个愚蠢的举动。

由于我在导入一些模块/lib(时间、选择、子进程)时遇到了一些错误。想到了重装python,一个很大的错误。我不幸跑了apt-get remove pythonsudo rm -rf /usr/bin/python* 我已经下载了Python-2.7.6.tgz 并尝试安装。编译时出现错误,make install

Compiling /usr/local/lib/python2.7/xmllib.py ...
Compiling /usr/local/lib/python2.7/xmlrpclib.py ...
Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1

有什么方法可以恢复或安装 python? apt-get -f install 报出如下错误

Removing libboost-python1.46-dev ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing libboost-python1.46-dev (--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>]
ImportError: No module named site
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 libboost-python1.46-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)

我已经导出了PYTHONHOME=/usr,但没有成功。这就是我现在运行python 时得到的 ImportError: No module named site

基本上我搞砸了python 操作系统:Ubuntu12.04 LTS - 服务器

更新:

这是我手动安装依赖项时遇到的错误

Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
  File "/usr/sbin/update-python-modules", line 13, in <module>
    from subprocess import call
  File "/usr/lib/python2.7/subprocess.py", line 427, in <module>
    import select
ImportError: /usr/lib/python2.7/site-packages/select.so: undefined symbol: _PyInt_AsInt

【问题讨论】:

  • 尝试恢复您的系统。通过apt-get 安装 Python。你也可以试试sudo apt-get install ubuntu-desktop
  • 有什么方法可以在不恢复系统的情况下做到这一点
  • apt-get install --reinstall python怎么样?
  • 第一句话不是任务,而是标题。
  • apt-get 命令不起作用。 E: Unmet dependencies. Try 'apt-get -f install' with no packages 是我遇到的错误

标签: python bash python-2.7 shell ubuntu


【解决方案1】:

我已经解决了

  • 检查了所有的依赖包

  • 下载了与上一个包指示的版本匹配的包并尝试安装

  • sudo dpkg -i --force-overwrite &lt;pkg&gt; 安装了软件包(请参阅 sebenalern 的答案以下载 包)

  • sudo dpkg -r &lt;pkg&gt;删除了未满足的依赖包

  • 已安装 python2.7_2.7.3-0ubuntu3.8_amd64.deb python2.7-minimal_2.7.3-0ubuntu3.8_amd64.deb libpython2.7_2.7.3-0ubuntu3.8_amd64.deb 一次 -> sudo dpkg -i *.deb

  • 很高兴apt-get 重新开始工作
  • sudo apt-get -f install
  • sudo apt-get install --reinstall python2.7。它已升级到 2.7.11
  • 对于我运行的所有缺少的 python 包sudo apt-get install ubuntu-desktop
  • 终于sudo apt-get autoremove

【讨论】:

    【解决方案2】:

    尝试使用安装新的 libboost sudo dpkg -i --force-overwrite libboost1.46-all-dev_1.46.1-7ubuntu3_amd64.deb

    你可以下载它here. 然后运行:

    sudo apt-get update &amp;&amp; sudo apt-get install -f &amp;&amp; sudo apt-get autoremove

    【讨论】:

    • 我都试过了,但都没用。它给出了相同的输出Errors were encountered while processing: libboost-python1.46-dev E: Sub-process /usr/bin/dpkg returned an error code (1)
    • 这行得通,但是对于其余的软件包,我遇到了错误,我已经在描述中更新了它。
    • 现在尝试设置 $PYTHONHOME
    • nope :( 同样的错误。我将 PYTHONHOME 设置为 /usr
    猜你喜欢
    • 2017-08-21
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多