我试图更新我的 Python 但结果却搞乱了整个系统。
我现在可以启动我的软件中心了。我尝试在 Google 上搜索多种修复方法,但都无济于事。我的软件中心无法启动。
当我尝试启动它时,显示以下错误:
astephen@localhost:/usr/bin$ ./software-centerGtk-Message: Failed to load module "gtk-vector-screenshot"
Traceback (most recent call last):
File "./software-center", line 36, in <module>
from softwarecenter.utils import (
File "/usr/share/software-center/softwarecenter/utils.py", line 19, in <module>
import dbus
ImportError: No module named dbus
我尝试dbus
使用以下方法重新安装:
apt-get install --reinstall dbus
但这并没有什么帮助。
astephen@localhost:/usr/bin$ sudo apt-get install --reinstall dbusReading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/231 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 676272 files and directories currently installed.)
Preparing to unpack .../dbus_1.6.18-0ubuntu4.3_amd64.deb ...
Unpacking dbus (1.6.18-0ubuntu4.3) over (1.6.18-0ubuntu4.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up dbus (1.6.18-0ubuntu4.3) ...
答案1
快速搜索后发现,Python DBUS 模块的 Debian 软件包名称为python-dbus
(或python3-dbus
)。为什么它尽管是该软件包的显式依赖项却不可用,software-center
我不明白。您应该重新安装这两个软件包,以防它们损坏:
sudo apt-get install --reinstall software-center python-dbus
答案2
好吧,这个问题已经问了两年了,但这并没有阻止我在同一个问题上浪费时间。
pip3 install dbus-python
让我遇到了一些问题,例如:
...
checking python extra linking flags... -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
checking consistency of all components of python development environment... no
configure: error: in `/tmp/pip-build-407jqhld/dbus-python/build/temp.linux-x86_64-3.7':
configure: error:
Could not link test program to Python. Maybe the main Python library has been
installed in some non-standard library path. If so, pass it to configure,
via the LIBS environment variable.
Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
See `config.log' for more details
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-407jqhld/dbus-python/setup.py", line 111, in <module>
tests_require=['tap.py'],
File "/home/schwaigeradm/.local/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/schwaigeradm/.local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 192, in run
self.run_command('build')
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-build-407jqhld/dbus-python/setup.py", line 64, in run
cwd=builddir)
File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/tmp/pip-build-407jqhld/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/usr/bin/python3', '--prefix=/tmp/pip-build-407jqhld/dbus-python/build/temp.linux-x86_64-3.7/prefix']' returned non-zero exit status 1.
----------------------------------------
Failed building wheel for dbus-python
Running setup.py clean for dbus-python
Failed to build dbus-python
安装或重新安装我当前的任何软件都无济于事。但我意识到这是一个 python3.7 问题:
与在 python2.7 中一样,可以添加 import dbus,但在 pyhon3.7 中它失败并出现相同的错误:
Traceback (most recent call last):
import dbus
File "/usr/lib/python3/dist-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/usr/lib/python3/dist-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ModuleNotFoundError: No module named '_dbus_bindings'
解决方案相当简单:
sudo apt-get install python3.7-dev
pip3 install dbus-python
答案3
您必须使用或安装dbus-python
包:pip
pip3
pip3 install dbus-python
或者
pip install dbus-python
您可能需要sudo
在上述命令之前。
答案4
如果您的 python3 模块找不到正确版本的软件包,则可能的一种方法是创建指向旧版本的符号链接。 如果是 dbus,您可以执行以下操作。 (假设您刚刚将 python3.5 升级到 python3.6)
$ cd /usr/lib/python3/dist-packages/ $ ln -s _dbus_glib_bindings.cpython-{35m,36m}-x86_64-linux-gnu.so
如果遇到更多错误,请尝试链接所有包。
a=$(find /usr/lib/python3/dist-packages -name '*35m*so')
b=$(echo $a | tr 35m 36m)
IFS=' ' read -r -a a <<< $a
IFS=' ' read -r -a b <<< $b
for ((i=0;i<${#a[@]};++i)); do
ln -s "${a[i]}" "${b[i]}"
done