Debian
在 Debian 8->9 升級期間損壞的 python
所以我正在按照這些說明將 Debian 8 升級到 9 。出了點問題,python 壞了,現在我在幾個小時後無法修復它。一些樣本:
# apt-get install --fix-broken Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following packages were automatically installed and are no longer required: coinor-libcoinmp1v5 kde-style-oxygen kde-style-oxygen-qt4 libboost-date-time1.62.0 libboost-filesystem1.62.0 libboost-iostreams1.62.0 ... libkf5mailcommon5 libkf5mailimporter5 libkf5messagecomposer5 libkf5messagelist5 libkf5sendlater5 libkf5templateparser5 libkjsembed4 libkntlm4 libokularcore7 liborcus-0.11-0 libpagemaker-0.0-0 libspeechd2 libwps-0.4-4 Use 'apt-get autoremove' to remove them. The following extra packages will be installed: accountsservice akonadi-backend-mysql akonadi-server akregator apper appstream appstream-index apt apt-utils ark baloo-kf5 bluedevil bluez ... python-mpi4py python-scipy python3 python3-apt python3-cffi-backend python3-chardet python3-crypto python3-cryptography python3-dbus python3-debian python3-decorator python3-dev python3-gi python3-idna python3-joblib python3-keyring python3-keyrings.alt python3-minimal python3-nose python3-numpy python3-pkg-resources python3-py python3-pyasn1 python3-pycurl python3-pyqt4 python3-pyqt5 python3-pytest python3-secretstorage python3-setuptools python3-simplejson python3-sip python3-six python3-software-properties python3-wheel python3-xdg python3.5 python3.5-dev qapt-batch qdbus qdbus-qt5 qml-module-org-kde-activities qml-module-org-kde-bluezqt qml-module-org-kde-draganddrop ... task-ssh-server tasksel tasksel-data uno-libs3 ure user-manager vlc vlc-bin vlc-data vlc-l10n vlc-nox vlc-plugin-base vlc-plugin-notify vlc-plugin-qt vlc-plugin-samba vlc-plugin-video-output Suggested packages: gnome-control-center akonadi-backend-postgresql akonadi-backend-sqlite limba apt-doc powermgmt-base pulseaudio-module-bluetooth bluez-alsa ... vlc-plugin-skins2 vlc-plugin-video-splitter vlc-plugin-visualization The following packages will be REMOVED: aptitude coinor-libcoinmp1 coinor-libcoinutils3 coinor-libosi1 gparted juk k3b k3b-i18n kaccessible katepart kde-baseapps kde-baseapps-bin ... task-kde-desktop vlc-plugin-pulse The following NEW packages will be installed: accountsservice appstream baloo-kf5 bluedevil bluez bluez-obexd breeze breeze-cursor-theme breeze-icon-theme catdoc coinor-libcoinmp1v5 ... python3-cffi-backend python3-crypto python3-cryptography python3-idna python3-keyring python3-keyrings.alt python3-py python3-pyasn1 python3-pycurl python3-pytest python3-secretstorage python3-xdg python3.5 python3.5-dev qdbus-qt5 qml-module-org-kde-activities ... python3-debian python3-decorator python3-dev python3-gi python3-joblib python3-minimal python3-nose python3-numpy python3-pkg-resources python3-pyqt4 python3-pyqt5 python3-setuptools python3-simplejson python3-sip python3-six python3-software-properties python3-wheel qapt-batch qdbus qml-module-qtquick-controls qml-module-qtquick-layouts qml-module-qtquick-window2 qml-module-qtquick2 qt4-designer qt4-dev-tools qt4-linguist-tools qt4-qmake qtbase5-dev-tools qtchooser qtcreator qtcreator-data qtdeclarative5-dev-tools qttools5-dev-tools software-properties-kde sqlitebrowser systemsettings task-desktop task-english task-ssh-server tasksel tasksel-data uno-libs3 ure vlc vlc-data vlc-nox vlc-plugin-notify vlc-plugin-samba 211 upgraded, 514 newly installed, 165 to remove and 243 not upgraded. 25 not fully installed or removed. Need to get 0 B/488 MB of archives. After this operation, 409 MB of additional disk space will be used. Do you want to continue? [Y/n] Reading changelogs... Done Extracting templates from packages: 100% Preconfiguring packages ... (Reading database ... 223763 files and directories currently installed.) Preparing to unpack .../software-properties-kde_0.96.20.2-1+deb9u1_all.deb ... Failed to import the site module Traceback (most recent call last): File "/usr/lib/python3.5/site.py", line 580, in <module> main() File "/usr/lib/python3.5/site.py", line 566, in main known_paths = addusersitepackages(known_paths) File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages user_site = getusersitepackages() File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/lib/python3.5/site.py", line 253, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var return get_config_vars().get(name) File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix from _sysconfigdata import build_time_vars File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module> from _sysconfigdata_m import * ImportError: No module named '_sysconfigdata_m' dpkg: warning: subprocess old pre-removal script returned error exit status 1 dpkg: trying script from the new package instead ... Failed to import the site module Traceback (most recent call last): File "/usr/lib/python3.5/site.py", line 580, in <module> main() File "/usr/lib/python3.5/site.py", line 566, in main known_paths = addusersitepackages(known_paths) File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages user_site = getusersitepackages() File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/lib/python3.5/site.py", line 253, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var return get_config_vars().get(name) File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix from _sysconfigdata import build_time_vars File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module> from _sysconfigdata_m import * ImportError: No module named '_sysconfigdata_m' dpkg: error processing archive /var/cache/apt/archives/software-properties-kde_0.96.20.2-1+deb9u1_all.deb (--unpack): subprocess new pre-removal script returned error exit status 1 Failed to import the site module Traceback (most recent call last): File "/usr/lib/python3.5/site.py", line 580, in <module> main() File "/usr/lib/python3.5/site.py", line 566, in main known_paths = addusersitepackages(known_paths) File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages user_site = getusersitepackages() File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/lib/python3.5/site.py", line 253, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var return get_config_vars().get(name) File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix from _sysconfigdata import build_time_vars File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module> from _sysconfigdata_m import * ImportError: No module named '_sysconfigdata_m' dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: /var/cache/apt/archives/software-properties-kde_0.96.20.2-1+deb9u1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
同樣在單個包裝上:
# apt-get install --reinstall python3-minimal Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: apper : Depends: packagekit (>= 0.8.6) but it is not going to be installed python3 : Depends: python3-minimal (= 3.4.2-2) but 3.5.3-1 is to be installed software-properties-kde : Depends: python3-software-properties (= 0.96.20.2-1+deb9u1) but 0.92.25debian1 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
與上面的python3或python基本相同
# dpkg --remove --force-remove-reinstreq --force-depends python3 dpkg: python3: dependency problems, but removing anyway as you requested: python3-pygments depends on python3:any (>= 3.3.2-2~). software-properties-common depends on python3 (>= 3.2.3-3~). python3-joblib depends on python3:any (>= 3.3.2-2~). python3-debian depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-ptyprocess depends on python3:any (>= 3.3.2-2~). python3-traitlets depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-decorator depends on python3 (>= 3.2.3-3~). dh-python depends on python3:any (>= 3.3.2-2~). debian-goodies depends on python3. python3-pykde4 depends on python3 (<< 3.5). python3-pykde4 depends on python3 (>= 3.4~). python3-pykde4 depends on python3 (<< 3.5). python3-pykde4 depends on python3 (>= 3.4~). python3-setuptools depends on python3:any (>= 3.3). python3-setuptools depends on python3:any (<< 3.5). python3-setuptools depends on python3:any (>= 3.3). python3-setuptools depends on python3:any (<< 3.5). python3-software-properties depends on python3 (>= 3.2.3-3~). python3-sip depends on python3 (>= 3.4~). python3-sip depends on python3 (<< 3.5). python3-sip depends on python3 (>= 3.4~). python3-sip depends on python3 (<< 3.5). unattended-upgrades depends on python3. python3-pip depends on python3:any (>= 3.4~). python3-chardet depends on python3. python3-chardet depends on python3:any (>= 3.3.2-2~). python3-chardet depends on python3. python3-chardet depends on python3:any (>= 3.3.2-2~). python3-pexpect depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-nose depends on python3; however: Package python3 is to be removed. python3-nose depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-nose depends on python3; however: Package python3 is to be removed. python3-nose depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-ipython-genutils depends on python3:any (>= 3.3.2-2~). python3-uno depends on python3 (>= 3.4~). python3-uno depends on python3 (<< 3.5). python3-uno depends on python3 (>= 3.4~). python3-uno depends on python3 (<< 3.5). python3-pyqt4 depends on python3 (>= 3.4~). python3-pyqt4 depends on python3 (<< 3.5). python3-pyqt4 depends on python3 (>= 3.4~). python3-pyqt4 depends on python3 (<< 3.5). python3-wcwidth depends on python3:any (>= 3.3.2-2~). lsb-release depends on python3:any (>= 3.4~). python3-gi depends on python3 (>= 3.4~). python3-gi depends on python3 (<< 3.5). python3-gi depends on python3 (>= 3.4~). python3-gi depends on python3 (<< 3.5). python3-pkg-resources depends on python3:any (>= 3.3). python3-pkg-resources depends on python3:any (<< 3.5). python3-pkg-resources depends on python3:any (>= 3.3). python3-pkg-resources depends on python3:any (<< 3.5). python3-wheel depends on python3:any (>= 3.3.2-2~). python3-wheel depends on python3. python3-wheel depends on python3:any (>= 3.3.2-2~). python3-wheel depends on python3. gdebi-core depends on python3:any (>= 3.3.2-2~). software-properties-kde depends on python3 (>= 3.2.3-3~). python3-dev depends on python3 (= 3.4.2-2). python3-six depends on python3:any (>= 3.3.2-2~). python3-simplejson depends on python3 (>= 3.4~). python3-simplejson depends on python3 (<< 3.5). python3-simplejson depends on python3 (>= 3.4~). python3-simplejson depends on python3 (<< 3.5). python3-pyqt5 depends on python3 (>= 3.4~). python3-pyqt5 depends on python3 (<< 3.5). python3-pyqt5 depends on python3 (>= 3.4~). python3-pyqt5 depends on python3 (<< 3.5). python3-numpy depends on python3 (>= 3.4~). python3-numpy depends on python3 (<< 3.5). python3-numpy depends on python3 (>= 3.4~). python3-numpy depends on python3 (<< 3.5). python3-ipython depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. ipython3 depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-dbus depends on python3 (<< 3.5). python3-dbus depends on python3 (>= 3.4~). python3-dbus depends on python3 (<< 3.5). python3-dbus depends on python3 (>= 3.4~). python3-apt depends on python3 (<< 3.5). python3-apt depends on python3 (>= 3.4~). python3-apt depends on python3 (<< 3.5). python3-apt depends on python3 (>= 3.4~). python3-prompt-toolkit depends on python3:any (>= 3.3.2-2~); however: Package python3 is to be removed. python3-simplegeneric depends on python3 (>= 3.1.3-13~). python3-pickleshare depends on python3:any (>= 3.3.2-2~). (Reading database ... 223763 files and directories currently installed.) Removing python3 (3.4.2-2) ... Failed to import the site module Traceback (most recent call last): File "/usr/lib/python3.5/site.py", line 580, in <module> main() File "/usr/lib/python3.5/site.py", line 566, in main known_paths = addusersitepackages(known_paths) File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages user_site = getusersitepackages() File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/lib/python3.5/site.py", line 253, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var return get_config_vars().get(name) File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix from _sysconfigdata import build_time_vars File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module> from _sysconfigdata_m import * ImportError: No module named '_sysconfigdata_m' dpkg: error processing package python3 (--remove): subprocess installed pre-removal script returned error exit status 1 Failed to import the site module Traceback (most recent call last): File "/usr/lib/python3.5/site.py", line 580, in <module> main() File "/usr/lib/python3.5/site.py", line 566, in main known_paths = addusersitepackages(known_paths) File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages user_site = getusersitepackages() File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/lib/python3.5/site.py", line 253, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var return get_config_vars().get(name) File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix from _sysconfigdata import build_time_vars File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module> from _sysconfigdata_m import * ImportError: No module named '_sysconfigdata_m' dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: python3
我已經嘗試過了,但是另一個失去的包中發生了錯誤:
# ln -fs /usr/lib/python3.5/plat-x86_64-linux-gnu/_sysconfigdata_m.py /usr/lib/python3.5/
現在很多東西都壞了:
# lsb_release -a Failed to import the site module Traceback (most recent call last): File "/usr/lib/python3.5/site.py", line 580, in <module> main() File "/usr/lib/python3.5/site.py", line 566, in main known_paths = addusersitepackages(known_paths) File "/usr/lib/python3.5/site.py", line 287, in addusersitepackages user_site = getusersitepackages() File "/usr/lib/python3.5/site.py", line 263, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/lib/python3.5/site.py", line 253, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/lib/python3.5/sysconfig.py", line 595, in get_config_var return get_config_vars().get(name) File "/usr/lib/python3.5/sysconfig.py", line 538, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/lib/python3.5/sysconfig.py", line 410, in _init_posix from _sysconfigdata import build_time_vars File "/usr/lib/python3.5/_sysconfigdata.py", line 6, in <module> from _sysconfigdata_m import * ImportError: No module named '_sysconfigdata_m'
但升級進行到一半:
# cat /etc/issue Debian GNU/Linux 9 \n \l # cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 9 (stretch)" NAME="Debian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" VERSION_CODENAME=stretch ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" # ll $(which python) lrwxrwxrwx 1 root root 9 Jan 24 2017 /usr/bin/python -> python2.7* # ll $(which python3) -rwxr-xr-x 1 root root 11855256 Jun 13 2019 /usr/bin/python3*
為什麼安裝程序堅持使用損壞的 python3 而不是 python(即 2.7)?我該如何解決這個爛攤子?
編輯:
# apt policy python3 E: Invalid operation policy # apt-cache policy python3 python3: Installed: 3.4.2-2 Candidate: 3.5.3-1 Version table: 3.5.3-1 0 500 http://httpredir.debian.org/debian/ stretch/main amd64 Packages *** 3.4.2-2 0 100 /var/lib/dpkg/status # uname -a Linux myserver2c 3.16.0-11-amd64 #1 SMP Debian 3.16.84-1 (2020-06-09) x86_64 GNU/Linux
問題來自安全儲存庫,它沒有正確設置。
替換網頁中描述的以下行:
deb http://security.debian.org stretch/updates main contrib non-free
和:
deb http://security.debian.org/debian-security stretch/updates main contrib non-free
然後執行:
sudo apt update sudo apt dist-upgrade
解決python報錯切換到python2.7。請參閱更改 Ubuntu 中的 Python3 預設版本。然後創建一個
/var/lib/dpkg/info/python3.postinst
具有以下內容的:#!/bin/bash /bin/true
然後執行:
sudo dpkg --configure -a sudo apt update sudo apt full-upgrade
如果仍然無法
/var/lib/dpkg/status
在備份後刪除 python3,則執行上述命令。