2013-04-29 2 views
3

실수로/usr/local/bin /에있는 파이썬 바이너리 파일을 대체했습니다. 그 이후로는 파이썬 스크립트를 실행할 수 없으며 파이썬의 대화식 모드를 실행할 수도 없습니다.파이썬이 작동하지 않습니다

$ 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' 

는 내가 가진 관련 질문 볼 수 있습니다 : 오류 "AttributeError를 '모듈'개체가 어떤 속성 '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) 
+0

왜 파이썬을 다시 설치하지 않습니까? – Isaac

+1

이미 시도했지만 작동하지 않습니다. – Geparada

+0

운영 체제는 무엇입니까? –

답변

4

문제는 대신 /usr/bin/python/usr/local/bin/python을 타격하고 있다는 것입니다 것으로 보인다.

루트로 ... ... 같은 뭔가를 실행하여 길에서

mv /usr/local/bin/python /usr/local/bin/python.old 

를 이동하거나 필요하지 않을 거라 확신하고 있다면, 그냥 삭제할 수 있습니다 와 ...

rm /usr/local/bin/python 

bash는 여전히 /usr/local/bin/python를 실행하려고하고 type python 인쇄 ... 실행하면

python is hashed (/usr/local/bin/python) 

... hash -r 해시 테이블을 지우십시오.

그것은 /usr/local/bin/python/usr/bin/python을 복사하는 것은 좋은 생각이 아니다, 그렇지 않으면 당신은 문제가 당신이 apt-get upgrade와 파이썬을 업데이트 다음 번에 얻을 수있다, 즉, 그것은 /usr/bin/python를 업데이트 하겠지만, /usr/local/bin/python은 여전히 ​​기본적으로 실행됩니다.

+0

그래, 그게 문제 야./usr/local/bin/python /usr/local/bin/python.old bash :/usr/local/bin/python : 그런 파일이나 디렉토리가 없다 ... 어떻게 bash에게/usr/bin/python을 사용하게 할 수 있습니까?/usr/local/bin/python insted ??? – Geparada

+0

cp/usr/bin/python/usr/local/bin /이 간단한 해결책이었습니다. 감사!!! – Geparada

+1

@Geparada'/ usr/local/bin/python'에 파일이 없다고 확신하는 경우,'hash -r'을 써서 bash 해시 테이블을 지우고'/ usr/bin/python'을 선택해야합니다 . – Aya

0

당신은 다시 설치해야 :

내가 다시 설치하려고

같은 오류가 나타납니다. 이것은 더 나은 해결책입니다. 이것은 우분투에 터미널이 설치된 내 즐겨 찾기 설치입니다. 시도 :이 디버깅을 위해 특별히 만든 파이썬 빌드 할 수있는 뭔가가 같은 Install Python and cherrypy

그리고 당신이이 질문에

Installation python

+0

내가 이것을 시도하면 같은 오류가 발생한다 :"AttributeError : '모듈'객체에는 'pydebug'속성이 없다" – Geparada

+0

대답에 애완 동물을 설치하는 방법을 시도하십시오 –

2

에 대한 답변을 찾아 본다.

난 당신이 apt-get을 파이썬을 다시 설치 좋을 것 :

sudo apt-get install --reinstall python2.7 

귀하의 질문은 같은 같은 this SO question about sys.pydebug

관련 문제