Python 3이 작동하지 않습니다.

Python 3이 작동하지 않습니다.

최근에 Python 3.5를 소스에서 설치했는데, 설치나 링크 중에 뭔가 잘못한 것 같습니다. 그 후 Ubuntu 패키지를 설치하는 데 문제가 있습니다. 예를 들어, 소프트웨어 속성-공통을 다시 설치한 후에도 add-apt-repository가 작동하지 않습니다.

$ add-apt-repository 
bash: /usr/bin/add-apt-repository: /usr/bin/python3: bad interpreter: No such file or directory

또한 apt-get install을 하면 다음 오류가 발생합니다.

$ sudo apt-get install libraw-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libraw-dev
0 upgraded, 1 newly installed, 0 to remove and 229 not upgraded.
3 not fully installed or removed.
Need to get 382 kB/391 kB of archives.
After this operation, 1,588 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libraw-dev amd64 0.15.4-1 [382 kB]
Fetched 382 kB in 0s (651 kB/s)    
Selecting previously unselected package libraw-dev:amd64.
(Reading database ... 295477 files and directories currently installed.)
Preparing to unpack .../libraw-dev_0.15.4-1_amd64.deb ...
Unpacking libraw-dev:amd64 (0.15.4-1) ...
Setting up python3.4 (3.4.3-1ubuntu1~14.04.5) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
dpkg: error processing package python3.4 (--configure):
 subprocess installed post-installation script returned error exit status 134
Setting up python3-commandnotfound (0.3ubuntu12) ...
/var/lib/dpkg/info/python3-commandnotfound.postinst: 6: /var/lib/dpkg/info/python3-commandnotfound.postinst: py3compile: not found
dpkg: error processing package python3-commandnotfound (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: error processing package software-properties-common (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Setting up libraw-dev:amd64 (0.15.4-1) ...
Errors were encountered while processing:
 python3.4
 python3-commandnotfound
 software-properties-common
E: Sub-process /usr/bin/dpkg returned an error code (1)

또한 ppa를 추가하려고 하면 다음 오류가 발생합니다.

$ sudo add-apt-repository ppa:dhor/myway
sudo: unable to execute /usr/bin/add-apt-repository: No such file or directory

무슨 일이에요, 어떤 아이디어라도 있나요?

답변1

  1. 먼저 Python 3의 핵심을 복원해야 합니다.

    sudo apt install -f --reinstall python3 python3.4 python3-minimal python3.4-minimal libpython3.4-minimal
    

    Python 3에 따라 패키지가 절반만 설치되어 작동하지 않는 경우 패키지를 다운로드하여 수동으로 설치하세요.

    cd /tmp
    apt-get download python3 python3.4 python3-minimal python3.4-minimal libpython3.4-minimal
    sudo dpkg -i *python3*.deb
    sudo apt install -f
    
  2. 패키지를 설치 debsums하고 다음을 수행하십시오.패키지 상태 점검나머지 패키지의 무결성을 확인하고 필요한 경우 다시 설치합니다.

답변2

Ubuntu에는 시스템 유틸리티가 작동하기 위해 의존하는 자체 Python 설치가 함께 제공됩니다. 이러한 유틸리티는 python, python2python3이러한 시스템 설치를 가리키는 데 의존합니다 . 불행하게도 소스에서 Python을 빌드/설치할 때 표준은 make install새로운 python/ python2(Python 2.x의 경우) 또는 python3(Python 3.x의 경우) 바이너리를 설치하여 결국 시스템 Python 설치를 섀도잉하고 문제를 일으킬 수 있습니다.

시스템을 수정한 후에는(David의 답변이 계속 진행되기를 바랍니다) 소스에서 컴파일된 Python을 로 (다시) 설치해야 합니다. make altinstall그러면 python3인터프리터가 버전별 python3.5. 이는 시스템 유틸리티가 사용하는 명령을 숨기지 않으므로 시스템 Python을 방해하지 않고 자신만의 Python을 설치하는 안전한 방법입니다.

관련 정보