완전한 기술

완전한 기술

내 Kubuntu 14.4(표준 Python 2.7.6 포함)에서 python.org의 소스에서 빌드한 후 Python 2.7.10을 설치하려고 하면 Python이 손상됩니다.Debian에서 최신 Python 버전을 독립적으로 설치하거나 업그레이드하는 방법은 무엇입니까?. 표준 명령을 사용하여 문제를 해결할 수 없습니다. 내 dpkg가 Python 설치로 인해 엉망이 되거나 손상된 것 같습니다. dpkg의 이러한 측면을 수정하고 싶습니다. 나는 이것이 파일 /var/lib/dpkg/status, /var/lib/dpkg/available특히 /var/lib/dpkg/info/*첫 번째 파일 과 관련이 있다고 생각합니다 . dpkg어떻게든 재설정 해야 할 것 같지만 ,진짜전문가가 없습니다. 제가 그렇게 생각하는 이유는 다음과 같습니다.

$ apt-cache policy python
python:
  Installed: 2.7.10-1
  Candidate: 2.7.10-1
  Version table:
*** 2.7.10-1 0
    100 /var/lib/dpkg/status
2.7.5-5ubuntu3 0
    500 http://de.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

$ /usr/bin/python2.7
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

이것Python 2.7.10을 설치하려고 한 이유예, 다른 프로그램에 필요하기 때문입니다(Python 2.7.6의 ssl/openssl 문제로 인해). 하지만 이제는 시스템을 수정하고 싶습니다. Python 2.7.6으로 만드세요.


완전한 기술

나는 우분투에 질문하여 이 문제를 해결하려고 노력하기 시작했습니다.https://askubuntu.com/questions/648424/muon-is-gone-after-change-of-python-issues-after-python-2-7-10-installation-on그러나 나는 거기에서 어떤 대답도 얻지 못했습니다. 어쩌면 잘못된 군중일 수도 있습니다. 그 이후로 많은 노력을 해왔고 문제가 무엇인지 알고 있지만 이를 달성하기 위한 단계는 없습니다.

muon을 설치할 수 없는 것부터 시작됩니다 sudo apg-get install muon.

$ sudo apt-get install muon
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 muon : Depends: apt-xapian-index but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

일반적인 조언(예:https://askubuntu.com/questions/118749/package-system-is-broken-how-to-fix-it)도움이 없습니다:

sudo apt-get autoremove
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get update
sudo apt-get upgrade -f
sudo apt-get -f install muon

또는

sudo apt-get -f install

또는

sudo dpkg --configure -a 
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install muon

또는

sudo apt-get -o dpkg::options::="--force-confnew" -o dpkg::options::="--force-confmiss" --reinstall install muon

도움이 안돼. 그래서 나는 노력했다

$ sudo apt-get install apt-xapian-index
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 apt-xapian-index : Depends: python-xapian (>= 1.0.2) but it is not going to be installed
                    Depends: python-apt (>= 0.7.93.2) but it is not going to be installed
                    Depends: python-debian (>= 0.1.14) but it is not going to be installed
                    Depends: python:any (>= 2.7.1-0ubuntu2)
E: Unable to correct problems, you have held broken packages.

문제가 다른 프로그램에서도 발생한다는 것을 발견했습니다.

$ sudo apt-get install meld 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 meld : Depends: python:any (>= 2.7.1-0ubuntu2)
        Depends: python-gtk2 (>= 2.14) but it is not going to be installed
        Depends: python-glade2 (>= 2.14) but it is not going to be installed
        Depends: python-gobject-2 (>= 2.16) but it is not going to be installed
        Recommends: python-gnome2 but it is not going to be installed
        Recommends: python-gconf but it is not going to be installed
        Recommends: python-gtksourceview2 (>= 2.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

그래서 시도해봤어(운이 없지)

$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python

다음도 도움이 되지 않습니다.

sudo dpkg -P python2.7
sudo apt-get install python2.7
sudo dpkg -P python-minimal
sudo apt-get autoremove && sudo apt-get clean sudo apt-get update && sudo apt-get -f install

나는 들어가고있다 (상태

$ apt-cache policy python
python:
  Installed: 2.7.10-1
  Candidate: 2.7.10-1
  Version table:
*** 2.7.10-1 0
    100 /var/lib/dpkg/status
2.7.5-5ubuntu3 0
    500 http://de.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

Python을 다시 설치해 보았지만 여전히 작동하지 않습니다.

$ sudo apt-get -o dpkg::options::="--force-confnew" -o dpkg::options::="--force-confmiss" --reinstall install python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reinstallation of python is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.

또는

$ sudo apt-get -o dpkg::options::="--force-confnew" -o dpkg::options::="--force-confmiss" --reinstall install python2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python2

그리고 제거 프로그램을 빌드하려고 해도 작동하지 않습니다.

~/Python-2.7.10$ sudo make uninstall 
make: *** No rule to make target `uninstall'.  Stop.

그래서 어떻게든 dpkg를 고쳐야 한다는 의심이 들기 시작했습니다.

$ apt-cache policy python
python:
  Installed: 2.7.10-1
  Candidate: 2.7.10-1
  Version table:
*** 2.7.10-1 0
    100 /var/lib/dpkg/status
2.7.5-5ubuntu3 0
    500 http://de.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

$ /usr/bin/python2.7
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

추가 정보(부록)

$ dpkg -l python* | grep -v ^un
Gewünscht=Unbekannt/Installieren/R=Entfernen/P=Vollständig Löschen/Halten
| Status=Nicht/Installiert/Config/U=Entpackt/halb konFiguriert/
    Halb installiert/Trigger erWartet/Trigger anhängig
|/ Fehler?=(kein)/R=Neuinstallation notwendig (Status, Fehler: GROSS=schlecht)
||/ Name                                        Version                                 Architektur  Beschreibung
+++-===========================================-=======================================-============-=====================================================================================================================================================================================================================
ii  python                                      2.7.10-1                                amd64        Python 2.7.10
ii  python-apt-common                           0.9.3.5ubuntu1                          all          Python interface to libapt-pkg (locales)
ii  python-chardet-whl                          2.2.1-2~ubuntu1                         all          universal character encoding detector
ii  python-colorama-whl                         0.2.5-0.1ubuntu2                        all          Cross-platform colored terminal text in Python - Wheels
ii  python-cups                                 1.9.66-0ubuntu2                         amd64        Python bindings for CUPS
rc  python-cupshelpers                          1.4.3+20140219-0ubuntu2.6               all          Python modules for printer configuration with CUPS
ii  python-dbus-dev                             1.2.0-2build2                           all          main loop integration development files for python-dbus
ii  python-distlib-whl                          0.1.8-1ubuntu1                          all          low-level components of python distutils2/packaging
rc  python-gobject-2                            2.28.6-12build1                         amd64        deprecated static Python bindings for the GObject library
ii  python-html5lib-whl                         0.999-3~ubuntu1                         all          HTML parser/tokenizer based on the WHATWG HTML5 specification
ii  python-ldb                                  1:1.1.16-1                              amd64        Python bindings for LDB
ii  python-minimal                              2.7.5-5ubuntu3                          amd64        minimal subset of the Python language (default version)
ii  python-ntdb                                 1.0-2ubuntu1                            amd64        Python bindings for NTDB
ii  python-pam                                  0.4.2-13.1ubuntu3                       amd64        Python interface to the PAM library
ii  python-pip-whl                              1.5.4-1ubuntu3                          all          alternative Python package installer
ii  python-renderpm                             3.0-1build1                             amd64        python low level render interface
ii  python-reportlab-accel                      3.0-1build1                             amd64        C coded extension accelerator for the ReportLab Toolkit
ii  python-requests-whl                         2.2.1-1ubuntu0.3                        all          elegant and simple HTTP library for Python, built for human beings
ii  python-setuptools-whl                       3.3-1ubuntu2                            all          Python Distutils Enhancements (wheel package)
ii  python-six-whl                              1.5.2-1ubuntu1                          all          Python 2 and 3 compatibility library (universal wheel)                                               
rc  python-support                              1.0.15                                  all          automated rebuilding support for Python modules                                                      
ii  python-talloc                               2.1.0-1                                 amd64        hierarchical pool based memory allocator - Python bindings                                           
ii  python-tdb                                  1.2.12-1                                amd64        Python bindings for TDB                                                                              
ii  python-twisted-bin                          13.2.0-1ubuntu1                         amd64        Event-based framework for internet applications                                                      
rc  python-twisted-core                         13.2.0-1ubuntu1                         all          Event-based framework for internet applications                                                      
rc  python-ubuntu-sso-client                    13.10-0ubuntu6                          all          Ubuntu Single Sign-On client - Python library                                                        
ii  python-urllib3-whl                          1.7.1-1ubuntu3                          all          HTTP library with thread-safe connection pooling                                                     
ii  python2.7                                   2.7.6-8ubuntu0.2                        amd64        Interactive high-level object-oriented language (version 2.7)                                        
ii  python2.7-minimal                           2.7.6-8ubuntu0.2                        amd64        Minimal subset of the Python language (version 2.7)                                                  
ii  python3                                     3.4.0-0ubuntu2                          amd64        interactive high-level object-oriented language (default python3 version)                            
ii  python3-apport                              2.14.1-0ubuntu3.11                      all          Python 3 library for Apport crash report handling                                                    
ii  python3-apt                                 0.9.3.5ubuntu1                          amd64        Python 3 interface to libapt-pkg                                                                     
ii  python3-aptdaemon                           1.1.1-1ubuntu5.2                        all          Python 3 module for the server and client of aptdaemon                                               
ii  python3-chardet                             2.2.1-2~ubuntu1                         all          universal character encoding detector for Python3                                                    
ii  python3-colorama                            0.2.5-0.1ubuntu2                        all          Cross-platform colored terminal text in Python - Python 3.x                                          
ii  python3-commandnotfound                     0.3ubuntu12                             all          Python 3 bindings for command-not-found.                                                             
ii  python3-dbus                                1.2.0-2build2                           amd64        simple interprocess messaging system (Python 3 interface)                                            
ii  python3-dbus.mainloop.qt                    4.10.4+dfsg-1ubuntu1                    amd64        D-Bus Support for PyQt4 with Python 3
ii  python3-debian                              0.1.21+nmu2ubuntu2                      all          Python 3 modules to work with Debian-related data formats
ii  python3-defer                               1.0.6-2build1                           all          Small framework for asynchronous programming (Python 3)
ii  python3-dev                                 3.4.0-0ubuntu2                          amd64        header files and a static library for Python (default)
ii  python3-distlib                             0.1.8-1ubuntu1                          all          low-level components of python distutils2/packaging
ii  python3-distupgrade                         1:0.220.7                               all          manage release upgrades
ii  python3-gdbm:amd64                          3.4.0-0ubuntu1                          amd64        GNU dbm database support for Python 3.x
ii  python3-gi                                  3.12.0-1ubuntu1                         amd64        Python 3 bindings for gobject-introspection libraries
ii  python3-html5lib                            0.999-3~ubuntu1                         all          HTML parser/tokenizer based on the WHATWG HTML5 specification (Python 3)
ii  python3-minimal                             3.4.0-0ubuntu2                          amd64        minimal subset of the Python language (default python3 version)
ii  python3-pip                                 1.5.4-1ubuntu3                          all          alternative Python package installer - Python 3 version of the package
ii  python3-pkg-resources                       3.3-1ubuntu2                            all          Package Discovery and Resource Access using pkg_resources
ii  python3-problem-report                      2.14.1-0ubuntu3.11                      all          Python 3 library to handle problem reports
ii  python3-pycurl                              7.19.3-0ubuntu3                         amd64        Python 3 bindings to libcurl
ii  python3-pykde4                              4:4.13.3-0ubuntu0.1                     amd64        Python 3 bindings for the KDE Development Platform
ii  python3-pyqt4                               4.10.4+dfsg-1ubuntu1                    amd64        Python3 bindings for Qt4
ii  python3-requests                            2.2.1-1ubuntu0.3                        all          elegant and simple HTTP library for Python3, built for human beings
ii  python3-setuptools                          3.3-1ubuntu2                            all          Python3 Distutils Enhancements
ii  python3-sip                                 4.15.5-1build1                          amd64        Python 3/C++ bindings generator runtime library
ii  python3-six                                 1.5.2-1ubuntu1                          all          Python 2 and 3 compatibility library (Python 3 interface)
ii  python3-software-properties                 0.92.37.3                               all          manage the repositories that you install software from
ii  python3-uno                                 1:4.2.8-0ubuntu2                        amd64        Python-UNO bridge
ii  python3-update-manager                      1:0.196.13                              all          python 3.x module for update-manager
ii  python3-urllib3                             1.7.1-1ubuntu3                          all          HTTP library with thread-safe connection pooling for Python3
ii  python3-wheel                               0.24.0-1~ubuntu1                        all          built-package format for Python
ii  python3-xkit                                0.5.0ubuntu2                            all          library for the manipulation of xorg.conf files (Python 3)
ii  python3.4                                   3.4.0-2ubuntu1.1                        amd64        Interactive high-level object-oriented language (version 3.4)
ii  python3.4-dev                               3.4.0-2ubuntu1.1                        amd64        Header files and a static library for Python (v3.4)
ii  python3.4-minimal                           3.4.0-2ubuntu1.1                        amd64        Minimal subset of the Python language (version 3.4)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04
Codename:       trusty

$ grep -P '^[ \t]*[^#[ \t]+' /etc/apt/sources.list /etc/apt/sources.list.d/*.list
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty main restricted
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty main restricted
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty universe
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty universe
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates universe
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-updates universe
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty multiverse
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty multiverse
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
/etc/apt/sources.list:deb http://de.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
/etc/apt/sources.list:deb-src http://de.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu trusty-security main restricted
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu trusty-security universe
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu trusty-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu trusty-security multiverse
/etc/apt/sources.list:deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
/etc/apt/sources.list:deb http://archive.canonical.com/ubuntu trusty partner
/etc/apt/sources.list:deb http://extras.ubuntu.com/ubuntu trusty main
/etc/apt/sources.list:deb http://cran.uni-muenster.de/bin/linux/ubuntu trusty/
/etc/apt/sources.list.d/fossfreedom-packagefixes-trusty.list:deb http://ppa.launchpad.net/fossfreedom/packagefixes/ubuntu trusty main
/etc/apt/sources.list.d/jitsi.list:deb http://download.jitsi.org/deb unstable/
/etc/apt/sources.list.d/leviatan1-ppa-trusty.list:deb http://ppa.launchpad.net/leviatan1/ppa/ubuntu trusty main

$ whereis python
python: /usr/bin/python /usr/bin/python3.4-config /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python2.7 /usr/bin/python3.4m-config /etc/python /etc/python3.4 /etc/python2.7 /usr/lib/python3.4 /usr/lib/python2.7 /usr/bin/X11/python /usr/bin/X11/python3.4-config /usr/bin/X11/python3.4 /usr/bin/X11/python3.4m /usr/bin/X11/python2.7 /usr/bin/X11/python3.4m-config /usr/local/lib/python3.4 /usr/local/lib/python2.7 /usr/include/python3.4 /usr/include/python3.4m /usr/share/python /usr/share/man/man1/python.1.gz

$ whereis python2.7
python2: /usr/bin/python2.7 /usr/bin/python2 /etc/python2.7 /usr/lib/python2.7 /usr/bin/X11/python2.7 /usr/bin/X11/python2 /usr/local/lib/python2.7 /usr/share/man/man1/python2.1.gz

답변1

설치한 Python 패키지가 배포판에서 제공한 패키지보다 최신 버전입니다. 예를 들어 python버전 2.7.10-1을 설치했지만 배포판에는 버전 2.7.5-5ubuntu3만 있습니다.

APT는 명시적으로 지시하지 않는 한 패키지를 다운그레이드하지 않습니다. 따라서 예를 들어 정확한 Python 버전에 의존하는 패키지를 설치하려고 하면 패키지를 python다운그레이드할 수 없기 때문에 작동하지 않습니다. apt-get --reinstall install pythonAPT가 Python을 2.7.5로 다운그레이드하지 않기 때문에 실패 할 수도 있습니다.

시스템을 복구하려면 APT가 다운그레이드를 수행하도록 허용해야 합니다. 이를 위해 다음을 정의합니다.APT 선호도. 다음을 /etc/apt/preferences.d/allow-downgrade포함하는 파일을 만듭니다.

Package: *
Pin: release o=Ubuntu
Pin-Priority: 1001

/etc/apt/preferences.d(+ )의 파일에는 /etc/apt/preferences여러 버전의 패키지를 사용할 수 있는 경우 "대상 배포판에서 최신 버전 선호"라는 기본 선택을 재정의하는 우선 순위 선언이 포함되어 있습니다. 패키지에 1000보다 큰 우선 순위를 할당하면 패키지가 우선 순위가 낮은 패키지보다 이전 버전인 경우에도 패키지가 먼저 선택됩니다. 설치된 패키지의 우선순위는 500이므로 Ubuntu의 패키지가 우선합니다. 자세한 내용은 다음을 참조하세요.

man apt_preferences

우선순위를 설정하고 나면 다음을 실행할 수 있을 것 같습니다.

apt-get update
apt-get upgrade

모든 패키지를 Ubuntu 버전으로 다운그레이드합니다(Ubuntu에 없는 패키지는 제거되지 않음). 동시에 실행 apt-get -f install하고 성공적으로 완료될 때까지 다른 소프트웨어를 설치하지 마십시오.

모두 다운그레이드한 후 환경설정 파일을 삭제하고 apt-get update다시 실행해 보세요.

답변2

나는 작동하는 단 하나의 방법을 찾았습니다.

  1. 1단계: 다음에서 Python 2.7 deb 패키지를 다운로드합니다.여기그리고 설치해 보세요

    sudo dpkg -i <package-name>
    
  2. dbkg 도구를 사용하여 Python과 관련된 모든 것을 나열하십시오.

    sudo dpkg -l | grep python
    
  3. 위에서 찾은 모든 항목 삭제

    sudo dpkg --purge --force-all 패키지 이름

  4. 하려고 노력하다

    sudo apt upgrade
    

마지막에는 깨진 패키지 목록이 제공됩니다. 3단계를 사용하여 제거하세요.

  1. sudo apt 업그레이드에 더 이상 오류가 나타나지 않을 때까지 3-4단계를 반복합니다.

  2. deb 패키지로 설치된 Python 2.7의 위치를 ​​사용하여 /usr/bin/python에 대한 심볼릭 링크를 생성해야 할 수도 있습니다. ( locate bin/python) 그리고ln -s <path> /usr/bin/python

  3. Python은 이 시점에서 수정되어야 합니다. 하지만 do-release-upgrade(LTS가 아닌 최신 우분투로 업데이트하는 방법을 알아보려면 매뉴얼을 읽어보세요)

관련 정보