'pip failed to install dbus-python

I planed to install dbus-python:

$ pip --version; python --version
pip 19.0.3 from /home/me/anaconda3/lib/python3.7/site-packages/pip (python 3.7)   
Python 3.7.3

The platform:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:    18.10
Codename:   cosmic

When I run pip install dbus-python, it reports these errors:

  checking for DBUS... no
  configure: error: in `/tmp/pip-install-hr9djbwg/dbus-python/build/temp.linux-x86_64-3.7':
  configure: error: The pkg-config script could not be found or is too old.  Make sure it
  is in your PATH or set the PKG_CONFIG environment variable to the full
  path to pkg-config.
  
  Alternatively, you may set the environment variables DBUS_CFLAGS
  and DBUS_LIBS to avoid the need to call pkg-config.
  See the pkg-config man page for more details.

Check

$ echo $PKG_CONFIG
#return nothing 

I installed pkg-config just now:

$ pkg-config --version
0.29.1

It still reports these errors:

  checking for DBUS... no
  configure: error: Package requirements (dbus-1 >= 1.8) were not met:
  
  No package 'dbus-1' found
  
  Consider adjusting the PKG_CONFIG_PATH environment variable if you
  installed software in a non-standard prefix.
  
  Alternatively, you may set the environment variables DBUS_CFLAGS
  and DBUS_LIBS to avoid the need to call pkg-config.
  See the pkg-config man page for more details.

However, the dbus-1 package cannot be installed:

$ pip install dbus-1
Collecting dbus-1
  Could not find a version that satisfies the requirement dbus-1 (from versions: )
No matching distribution found for dbus-1


Solution 1:[1]

First I looked up for package

sudo apt-cache search dbus-1

Then I installed required packages with command:

sudo apt install libdbus-1-3 libdbus-1-dev

Solution 2:[2]

Encountered the same problem. dbus-python seems to be a deprecated module. dbus-next seems to its replacement.

pip install dbus-next

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vinzee
Solution 2 vinzee