ImportError: No module named dbus
I was trying to update my Python and messed up my whole system.
I am currently now able to start my Software Centre. I tried Googling multiple fixes but nothing helped. My Software Centre can't start.
When I try starting it up, this error shows:
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
I tried reinstalling dbus
using:
apt-get install --reinstall dbus
But it did not help.
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) ...
Solution 1:
A quick search reveals that the name of the Debian package for the Python DBUS module is called python-dbus
(or python3-dbus
). Why it isn't available despite being an explicit dependency of the software-center
package is beyond me. You should re-install the two packages in case they were corrupted:
sudo apt-get install --reinstall software-center python-dbus
Solution 2:
Ok, it's been two years since that question was asked, but this didn't stop me to waste my time on the same problem.
pip3 install dbus-python
made me just run into some problems like:
...
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
Installing or re-installing of any of my current software didn't help. But I realized it's a python3.7 issue:
As in python2.7 it was possible to add import dbus, but in pyhon3.7 it failed with the same error:
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'
The solution is rather easy:
sudo apt-get install python3.7-dev
pip3 install dbus-python