我的python没有';行不通

我的python没有';行不通,python,Python,我意外地替换了位于/usr/local/bin/的python二进制文件。从那时起,我就不能运行任何python脚本,甚至不能运行python的交互模式 $ python Traceback (most recent call last): File "/usr/lib/python2.7/site.py", line 562, in <module> main() File "/usr/lib/python2.7/site.py", line 544, in mai

我意外地替换了位于/usr/local/bin/的python二进制文件。从那时起,我就不能运行任何python脚本,甚至不能运行python的交互模式

$ python
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 558, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 457, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 303, in _init_posix
    makefile = _get_makefile_filename()
  File "/usr/lib/python2.7/sysconfig.py", line 297, in _get_makefile_filename
    return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
$python
回溯(最近一次呼叫最后一次):
文件“/usr/lib/python2.7/site.py”,第562行,在
main()
文件“/usr/lib/python2.7/site.py”,第544行,在main中
已知路径=addusersitepackages(已知路径)
addusersitepackages中的文件“/usr/lib/python2.7/site.py”,第271行
user\u site=getusersitepackages()
getusersitepackages中的文件“/usr/lib/python2.7/site.py”,第246行
user_base=getuserbase()#这也将设置user_base
getuserbase中的文件“/usr/lib/python2.7/site.py”,第236行
USER\u BASE=get\u config\u var('userbase')
文件“/usr/lib/python2.7/sysconfig.py”,第558行,在get\u config\u var中
返回get_config_vars().get(name)
文件“/usr/lib/python2.7/sysconfig.py”,第457行,在get\u config\u vars中
_init_posix(_CONFIG_VARS)
文件“/usr/lib/python2.7/sysconfig.py”,第303行,在_init_posix中
makefile=\u get\u makefile\u filename()
文件“/usr/lib/python2.7/sysconfig.py”,第297行,在文件名
返回os.path.join(get_path('platstdlib')。替换(“/usr/local”,“/usr”,1),“config”+(sys.pydebug和“\u d”或“),“Makefile”)
AttributeError:“模块”对象没有属性“pydebug”
我看到了“AttributeError:‘module’对象没有属性‘pydebug’”错误的相关问题,但我仍然不知道如何解决这个问题

当我尝试重新安装时,出现相同的错误:

$ sudo apt-get install python2.7-minimal
[sudo] password for : 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python2.7-minimal is already the newest version.
The following packages were automatically installed and are no longer required:
  libgsasl7 libmailutils2 libntlm0
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 402 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
Setting up python2.7-minimal (2.7.1-5ubuntu2.2) ...
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 558, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 457, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 303, in _init_posix
    makefile = _get_makefile_filename()
  File "/usr/lib/python2.7/sysconfig.py", line 297, in _get_makefile_filename
    return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
dpkg: error processing python2.7-minimal (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python2.7:
 python2.7 depends on python2.7-minimal (= 2.7.1-5ubuntu2.2); however:
  Package python2.7-minimal is not configured yet.
dpkg: error processing python2.7 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libpython2.7:
 libpython2.7 depends on python2.7 (= 2.7.1-5ubuntu2.2); however:
  Package python2.7 is not configured yet.
dpkg: error processing libpython2.7 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python2.7-dev:
 python2.7-dev depends on python2.7 (= 2.7.1-5ubuntu2.2); however:
  Package python2.7 is not configured yet.
 python2.7-dev depeNo apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                                             No apport report written because the error message indicates its a followup error from a previous failure.
                                                                          No apport report written because MaxReports is reached already
                                                                                                                                        nds on libpython2.7 (= 2.7.1-5ubuntu2.2); however:
  Package libpython2.7 is not configured yet.
dpkg: error processing python2.7-dev (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python2.7-minimal
 python2.7
 libpython2.7
 python2.7-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
$sudo apt get install python2.7-minimal
[sudo]的密码:
正在阅读软件包列表。。。多恩
构建依赖树
正在读取状态信息。。。多恩
python2.7-minimal已经是最新版本了。
以下软件包已自动安装,不再需要:
libgsasl7 libmailutils2 libntlm0
使用“apt get autoremove”删除它们。
0已升级,0已新安装,0已删除,402未升级。
4未完全安装或拆除。
执行此操作后,将使用0 B的额外磁盘空间。
是否要继续[Y/n]?Y
设置python2.7-minimal(2.7.1-5ubuntu2.2)。。。
回溯(最近一次呼叫最后一次):
文件“/usr/lib/python2.7/site.py”,第562行,在
main()
文件“/usr/lib/python2.7/site.py”,第544行,在main中
已知路径=addusersitepackages(已知路径)
addusersitepackages中的文件“/usr/lib/python2.7/site.py”,第271行
user\u site=getusersitepackages()
getusersitepackages中的文件“/usr/lib/python2.7/site.py”,第246行
user_base=getuserbase()#这也将设置user_base
getuserbase中的文件“/usr/lib/python2.7/site.py”,第236行
USER\u BASE=get\u config\u var('userbase')
文件“/usr/lib/python2.7/sysconfig.py”,第558行,在get\u config\u var中
返回get_config_vars().get(name)
文件“/usr/lib/python2.7/sysconfig.py”,第457行,在get\u config\u vars中
_init_posix(_CONFIG_VARS)
文件“/usr/lib/python2.7/sysconfig.py”,第303行,在_init_posix中
makefile=\u get\u makefile\u filename()
文件“/usr/lib/python2.7/sysconfig.py”,第297行,在文件名
返回os.path.join(get_path('platstdlib')。替换(“/usr/local”,“/usr”,1),“config”+(sys.pydebug和“\u d”或“),“Makefile”)
AttributeError:“模块”对象没有属性“pydebug”
dpkg:处理python2.7时出错-最小(--配置):
安装的子进程安装后脚本返回错误退出状态1
dpkg:依赖性问题阻止配置python2.7:
python2.7取决于python2.7-最小值(=2.7.1-5ubuntu2.2);然而:
尚未配置程序包python2.7-minimal。
dpkg:处理python2.7时出错(--configure):
依赖关系问题-保持未配置状态
dpkg:依赖性问题阻止配置libpython2.7:
libpython2.7取决于python2.7(=2.7.1-5ubuntu2.2);然而:
尚未配置python2.7包。
dpkg:处理libpython2.7时出错(--configure):
依赖关系问题-保持未配置状态
dpkg:依赖性问题阻止配置python2.7-dev:
python2.7-dev依赖于python2.7(=2.7.1-5ubuntu2.2);然而:
尚未配置python2.7包。
python2.7-dev depeNo apport报告已写入,因为错误消息表明它是以前失败的后续错误。
未写入apport报告,因为错误消息表明它是以前失败的后续错误。
未写入apport报告,因为已到达MaxReports
libpython2.7(=2.7.1-5ubuntu2.2)上的nds;然而:
尚未配置程序包libpython2.7。
dpkg:处理python2.7-dev(--configure)时出错:
依赖关系问题-保持未配置状态
处理时遇到错误:
python2.7-minimal
蟒蛇2.7
libpython2.7
python2.7-dev
E:子流程/usr/bin/dpkg返回错误代码(1)
您必须重新安装。 这是一个更好的解决方案。 这是Ubuntu上带有终端的my favoruite安装。 尝试:

你看看这个问题的答案


看起来这与专门为调试而制作的Python构建有关

我建议您使用apt get重新安装Python:

sudo apt-get install --reinstall python2.7

您的问题似乎与

相同。问题是您所点击的是
/usr/local/bin/python
,而不是
/usr/bin/python

你可以通过运行一些类似于

mv /usr/local/bin/python /usr/local/bin/python.old
…作为根目录,或者如果您确定不需要它,则只需使用

rm /usr/local/bin/python
如果bash仍然尝试运行
/usr/local/bin/python
,并且运行
键入python
打印

python is hashed (/usr/local/bin/python)
…然后执行
哈希-r
以清除哈希选项卡