我在 Ubuntu 上安装了 pip 和 python2.7,它们运行良好。我安装了 python3.6。每当我尝试使用 pip3 时,都会出现错误:
Traceback (most recent call last):
File "/usr/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
每当我跑步时:
sudo apt-get install python3-pip
我收到错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
2 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.4.0-0ubuntu2) ...
running python rtupdate hooks for python3.4...
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook dh-python
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook gdebi-core
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook gdebi
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook ibus
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook onboard
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook python3-uno
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox-plugin-magnatune
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox-plugin-zeitgeist
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox-plugins
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook rhythmbox
E: py3compile:243: Requested versions are not installed
error running python rtupdate hook ubuntu-drivers-common
dpkg: error processing package python3 (--configure):
subprocess installed post-installation script returned error exit status 4
dpkg: dependency problems prevent configuration of python3-pip:
python3-pip depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
python3-pip depends on python3; however:
Package python3 is not configured yet.
dpkg: error processing package python3-pip (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
python3
python3-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
我真的需要帮助。谢谢!
运行后sudo apt-get install --reinstall python3-pkg-resources python3-minimal
出现错误...这是输出;
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 2 reinstalled, 0 to remove and 17 not upgraded.
2 not fully installed or removed.
Need to get 54.9 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://ng.archive.ubuntu.com/ubuntu/ trusty/main python3-minimal amd64 3.4.0-0ubuntu2 [23.2 kB]
Get:2 http://ng.archive.ubuntu.com/ubuntu/ trusty-updates/main python3-pkg-resources all 3.3-1ubuntu2 [31.7 kB]
Fetched 54.9 kB in 2s (25.7 kB/s)
(Reading database ... 246854 files and directories currently installed.)
Preparing to unpack .../python3-minimal_3.4.0-0ubuntu2_amd64.deb ...
Unpacking python3-minimal (3.4.0-0ubuntu2) over (3.4.0-0ubuntu2) ...
Preparing to unpack .../python3-pkg-resources_3.3-1ubuntu2_all.deb ...
/var/lib/dpkg/info/python3-pkg-resources.prerm: 6: /var/lib/dpkg/info/python3-pkg-resources.prerm: py3clean: not found
dpkg: warning: subprocess old pre-removal script returned error exit status 127
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: py3clean: not found
dpkg: error processing archive /var/cache/apt/archives/python3-pkg-resources_3.3-1ubuntu2_all.deb (--unpack):
subprocess new pre-removal script returned error exit status 127
/var/lib/dpkg/info/python3-pkg-resources.postinst: 6: /var/lib/dpkg/info/python3-pkg-resources.postinst: py3compile: not found
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 127
Processing triggers for man-db (2.7.0.2-2) ...
Errors were encountered while processing:
/var/cache/apt/archives/python3-pkg-resources_3.3-1ubuntu2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
现在……我真的很困惑。每当我尝试安装任何东西时,都会出现错误。错误如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reinstallation of dh-python is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
4 not fully installed or removed.
Need to get 0 B/31.7 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-minimal (3.4.0-0ubuntu2) ...
/var/lib/dpkg/info/python3-minimal.postinst: 5: /var/lib/dpkg/info/python3-minimal.postinst: py3compile: not found
dpkg: error processing package python3-minimal (--configure):
subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python3:
python3 depends on python3-minimal (= 3.4.0-0ubuntu2); however:
Package python3-minimal is not configured yet.
dpkg: error processing package python3 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pkg-resources:
python3-pkg-resources depends on python3:any (>= 3.4); however:
Package python3 is not configured yet.
python3-pkg-resources depends on python3:any (<< 3.5); however:
Package python3 is not configured yet.
dpkg: error processing package python3-pkg-resources (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-pip:
python3-pip depends on python3-pkg-resources; however:
Package python3-pkg-resources is not configured yet.
python3-pip depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
python3-pip depends on python3; however:
Package pythNo 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
on3 is not configured yet.
dpkg: error processing package python3-pip (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3-minimal
python3
python3-pkg-resources
python3-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
在聊天过程中,我们已确定,py3compile
并且py3clean
由于以下原因而中断:python3和python3.4:
$ file /usr/bin/python3 /usr/bin/python3: broken symbolic link to `python3.4'
因此我们需要重新安装 Python 3 包:
sudo apt-get install --reinstall libpython3.4 python3.4 python3-gdbm libpython3.4-stdlib libpython3.4-dev libpython3.4-minimal
最后重新安装所有相关的其他内容pkg_资源,py3编译和py3clean:
sudo apt-get install --reinstall python3-pkg-resources python3-minimal
sudo apt-get install --reinstall dh-python
然后重试
sudo dpkg --configure -a
sudo apt-get install -f
sudo apt-get install python3-pip
sudo apt-get dist-upgrade