我如何安装 python3?
我尝试像这样安装 python3:
sudo apt-get install python3
但我收到以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version.
The following packages were automatically installed and are no longer required:
apport-symptoms caribou digikam-data enblend enfuse finger gcc-4.7-base:i386 gir1.2-accounts-1.0 gir1.2-gdata-0.0 gir1.2-goa-1.0 gir1.2-muffin-3.0
gir1.2-signon-1.0 gnome-applets-data gnome-media gstreamer0.10-gconf icoutils kde-runtime-data kipi-plugins-common lib32z1 libc6-i386
libgnome-media-profiles-3.0-0 libkactivities-bin libkactivities6 libkcalcore4 libkdcraw-data libkdcraw21 libkdeclarative5 libkdesu5 libkdnssd4
libkexiv2-11 libkexiv2-data libkface-data libkface1 libkgeomap-data libkgeomap1 libkipi-data libkipi9 libkmediaplayer4 libknotifyconfig4 libksane-data
libksane0 libkvkontakte1 libkxmlrpcclient4 liblensfun-data liblensfun0 libmail-sendmail-perl libmarblewidget14 libmediawiki1 libmuffin0
libnemo-extension1 libnepomuksync4 libntrack-qt4-1 libntrack0 libopencv-calib3d2.3 libopencv-core2.3 libopencv-features2d2.3 libopencv-flann2.3
libopencv-highgui2.3 libopencv-imgproc2.3 libopencv-legacy2.3 libopencv-objdetect2.3 libopencv-video2.3 libplasma3 libplot2c2 libqapt-runtime libqapt1
librpmbuild3 librpmsign1 libsys-hostname-long-perl libthreadweaver4 muffin-common ncurses-term nepomuk-core ntrack-module-libnl-0 oxygen-icon-theme pax
plasma-scriptengine-javascript po-debconf python-gpgme python-lxml rpm shared-desktop-ontologies
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
21 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 python3.3-minimal (3.3.2-7ubuntu3.1) ...
Traceback (most recent call last):
File "/usr/lib/python3.3/py_compile.py", line 8, in <module>
import imp
File "/usr/lib/python3.3/imp.py", line 28, in <module>
import tokenize
File "/usr/lib/python3.3/tokenize.py", line 28, in <module>
import re
File "/usr/lib/python3.3/re.py", line 122, in <module>
import sre_compile
File "/usr/lib/python3.3/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/lib/python3.3/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/lib/python3.3/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
dpkg: error processing python3.3-minimal (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python3-minimal:
python3-minimal depends on python3.3-minimal (>= 3.3.1-1~); however:
Package python3.3-minimal is not configured yet.
dpkg: error processing python3-minimal (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3.3:
python3.3 depends on python3.3-minimal (= 3.3.2-7ubuntu3.1); however:
Package python3.3-minimal is not configured yet.
dpkg: error processing python3.3 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3:
python3 depends on python3.3 (>= 3.3.1-1~); however:
Package python3.3 is not configured yet.
python3 depends on python3-minimal (= 3.3.2-14ubuntu1); however:
Package python3-minimal is not configured yet.
dpkg: error processing python3 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-gi:
python3-gi depends on python3 (<< 3.4); however:
Package python3 is not configured yet.
python3-gi depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
python3-gi depends on python3 (>= 3.3); however:
Package python3 is not configured yet.
dpkg: error processing python3-gi (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-dbus:
python3-dbus depends on python3 (>= 3.3); however:
Package python3 is not configured yet.
python3-dbus depends on python3 (<< 3.4); however:
Package python3 is not configured yet.
dpkg: error processing python3-dbus (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of bluez:
bluez depends on python3-dbus; however:
Package python3-dbus is not configured yet.
dpkg: error processing bluez (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of lsb-release:
lsb-release depends on python3 (>= 3.2.3-3~); however:
Package python3 is not configured yet.
dpkg: error processing lsb-release (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-apt:
python3-apt depends on python3 (>= 3.3); however:
Package python3 is not configured yet.
python3-apt depends on python3 (<< 3.4); however:
Package python3 is not configured yet.
dpkg: error processing python3-apt (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gnome-menus:
gnome-menus depends on python3; however:
Package python3 is not configured yet.
gnome-menus depends on python3:any (>= 3.1); however:
Package python3 is not configured yet.
dpkg: error processing gnome-menus (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gnome-control-center:
gnome-control-center depends on gnome-menus (>= 2.12.0); however:
Package gnome-menus is not configured yet.
dpkg: error processing gnome-control-center (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gnome-bluetooth:
gnome-bluetooth depends on bluez (>= 4.36); however:
Package bluez is not configured yet.
dpkg: error processing gnome-bluetooth (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of indicator-bluetooth:
indicator-bluetooth depends on bluez (>= 4.36); however:
Package bluez is not configured yet.
indicator-bluetooth depends on gnome-control-center | ubuntu-system-settings; however:
Package gnome-control-center is not configured yet.
Package ubuntu-system-settings is not installed.
indicator-bluetooth depends on gnome-bluetooth | ubuntu-system-settings; however:
Package gnome-bluetooth is not configured yet.
Package ubuntu-system-settings is not installed.
dpkg: error processing indicator-bluetooth (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of gnome-user-share:
gnome-user-share depends on gnome-bluetooth; however:
Package gnome-bluetooth is not configured yet.
dpkg: error processing gnome-user-share (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pkg-resources:
python3-pkg-resources depends on python3 (>= 3.2); however:
Package python3 is not configured yet.
python3-pkg-resources depends on python3 (<< 3.4); however:
Package python3 is not configured yet.
dpkg: error processing python3-pkg-resources (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-defer:
python3-defer depends on python3 (>= 3.2); however:
Package python3 is not configured yet.
dpkg: error processing python3-defer (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-aptdaemon:
python3-aptdaemon depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
python3-aptdaemon depends on python3-apt (>= 0.8.5~ubuntu1); however:
Package python3-apt is not configured yet.
python3-aptdaemon depends on python3-defer (>= 1.0.6); however:
Package python3-defer is not configured yet.
python3-aptdaemon depends on python3-dbus; however:
Package python3-dbus is not configured yet.
python3-aptdaemon depends on python3-gi; however:
Package python3-gi is not configured yet.
python3-aptdaemon depends on python3-pkg-resources; however:
Package python3-pkg-resources is not configured yet.
dpkg: error processing python3-aptdaemon (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-aptdaemon.pkcompat:
python3-aptdaemon.pkcompat depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
python3-aptdaemon.pkcompat depends on python3-aptdaemon (= 1.1.1-0ubuntu4); however:
Package python3-aptdaemon is not configured yet.
dpkg: error processing python3-aptdaemon.pkcompat (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of system-config-printer-gnome:
system-config-printer-gnome depends on packagekit-system-interface; however:
Package packagekit-system-interface is not installed.
Package python3-aptdaemon.pkcompat which provides packagekit-system-interface is not configured yet.
dpkg: error processing system-config-printer-gnome (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of aptdaemon:
aptdaemon depends on python3:any (>= 3.2); however:
Package python3 is not configured yet.
aptdaemon depends on python3.3; however:
Package python3.3 is not configured yet.
aptdaemon depends on python3-aptdaemon (= 1.1.1-0ubuntu4); however:
Package python3-aptdaemon is not configured yet.
aptdaemon depends on python3-gi; however:
Package python3-gi is not configured yet.
dpkg: error processing aptdaemon (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of dh-python:
dh-python depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
dpkg: error processing dh-python (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3.3-minimal
python3-minimal
python3.3
python3
python3-gi
python3-dbus
bluez
lsb-release
python3-apt
gnome-menus
gnome-control-center
gnome-bluetooth
indicator-bluetooth
gnome-user-share
python3-pkg-resources
python3-defer
python3-aptdaemon
python3-aptdaemon.pkcompat
system-config-printer-gnome
aptdaemon
dh-python
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我做:
sudo dpkg --configure python3
我得到:
dpkg: dependency problems prevent configuration of python3:
python3 depends on python3.3 (>= 3.3.1-1~); however:
Package python3.3 is not configured yet.
python3 depends on python3-minimal (= 3.3.2-14ubuntu1); however:
Package python3-minimal is not configured yet.
python3 depends on dh-python; however:
Package dh-python is not configured yet.
dpkg: error processing python3 (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3
当我这样做的时候:
sudo dpkg --configure python3.3-minimal
我得到:
Setting up python3.3-minimal (3.3.2-7ubuntu3.1) ...
Traceback (most recent call last):
File "/usr/lib/python3.3/py_compile.py", line 8, in <module>
import imp
File "/usr/lib/python3.3/imp.py", line 28, in <module>
import tokenize
File "/usr/lib/python3.3/tokenize.py", line 28, in <module>
import re
File "/usr/lib/python3.3/re.py", line 122, in <module>
import sre_compile
File "/usr/lib/python3.3/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/lib/python3.3/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/lib/python3.3/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
dpkg: error processing python3.3-minimal (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
python3.3-minimal
根据用户 193537 的评论进行编辑:
当我尝试删除 python3 时:
sudo apt-get remove python3
然后我得到了这个依赖问题:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'python3' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python3.3-minimal (3.3.2-7ubuntu3.1) ...
Traceback (most recent call last):
File "/usr/lib/python3.3/py_compile.py", line 8, in <module>
import imp
File "/usr/lib/python3.3/imp.py", line 28, in <module>
import tokenize
File "/usr/lib/python3.3/tokenize.py", line 28, in <module>
import re
File "/usr/lib/python3.3/re.py", line 122, in <module>
import sre_compile
File "/usr/lib/python3.3/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/lib/python3.3/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/lib/python3.3/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
dpkg: error processing python3.3-minimal (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python3.3:
python3.3 depends on python3.3-minimal (= 3.3.2-7ubuntu3.1); however:
Package python3.3-minimal is not configured yet.
dpkg: error processing python3.3 (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3.3-minimal
python3.3
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
@Gx1sptDTDa 在这里回答了我的问题:
Gx1sptDTDa 链接到:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1165281
解决方法是编辑这些文件:
/usr/lib/python3.3/sre_constants.py
/usr/lib/python3.3/sre_parse.py
/usr/lib/python3.3/sre_compile.py
在 sre_constants.py 中我替换:
from _sre import MAXREPEAT
和:
MAXREPEAT = 65535
#from _sre import MAXREPEAT
在 sre_parse.py 和 sre_compile.py 中我注释掉了:
from _sre import MAXREPEAT