Error while installing spotify

Hi,

if I try to install spotify I get the following error.

pi@testpi4:~ $ sudo python3 -m pip install Mopidy-Spotify
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting Mopidy-Spotify
  Using cached https://files.pythonhosted.org/packages/1c/41/1d5b1b6534cf5ad209ba8b814132cfdadf8dcda87024beabb42c1f88ce22/Mopidy_Spotify-4.0.1-py3-none-any.whl
Requirement already satisfied: Mopidy>=3.0.0 in /usr/lib/python3/dist-packages (from Mopidy-Spotify) (3.0.2)
Requirement already satisfied: requests>=2.20.0 in /usr/lib/python3/dist-packages (from Mopidy-Spotify) (2.21.0)
Requirement already satisfied: Pykka>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from Mopidy-Spotify) (2.0.2)
Collecting pyspotify>=2.0.5 (from Mopidy-Spotify)
  Using cached https://files.pythonhosted.org/packages/fe/1d/83d088397d95eacf6281ae748886d024aab50efdea50aedf8f294fc53aa7/pyspotify-2.1.3.tar.gz
  Installing build dependencies ... done
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from Mopidy-Spotify) (40.8.0)
Requirement already satisfied: cffi>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from pyspotify>=2.0.5->Mopidy-Spotify) (1.14.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi>=1.0.0->pyspotify>=2.0.5->Mopidy-Spotify) (2.20)
Building wheels for collected packages: pyspotify
  Running setup.py bdist_wheel for pyspotify ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-q3bwqnov/pyspotify/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-jh5s5so0 --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-armv7l-3.7
  creating build/lib.linux-armv7l-3.7/spotify
  copying spotify/user.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/playlist_track.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/offline.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/compat.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/error.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/eventloop.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/inbox.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/connection.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/sink.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/artist.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/config.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/link.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/toplist.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/playlist_container.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/session.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/image.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/social.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/__init__.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/playlist_unseen_tracks.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/album.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/playlist.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/_spotify_build.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/version.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/search.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/player.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/utils.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/track.py -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/audio.py -> build/lib.linux-armv7l-3.7/spotify
  running egg_info
  writing pyspotify.egg-info/PKG-INFO
  writing dependency_links to pyspotify.egg-info/dependency_links.txt
  writing requirements to pyspotify.egg-info/requires.txt
  writing top-level names to pyspotify.egg-info/top_level.txt
  reading manifest file 'pyspotify.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*' under directory '.github'
  no previously-included directories found matching 'docs/_build'
  no previously-included directories found matching 'examples/tmp'
  warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
  writing manifest file 'pyspotify.egg-info/SOURCES.txt'
  copying spotify/api.h -> build/lib.linux-armv7l-3.7/spotify
  copying spotify/api.processed.h -> build/lib.linux-armv7l-3.7/spotify
  running build_ext
  generating cffi module 'build/temp.linux-armv7l-3.7/spotify._spotify.c'
  creating build/temp.linux-armv7l-3.7
  building 'spotify._spotify' extension
  creating build/temp.linux-armv7l-3.7/build
  creating build/temp.linux-armv7l-3.7/build/temp.linux-armv7l-3.7
  arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c build/temp.linux-armv7l-3.7/spotify._spotify.c -o build/temp.linux-armv7l-3.7/build/temp.linux-armv7l-3.7/spotify._spotify.o
  build/temp.linux-armv7l-3.7/spotify._spotify.c:540:10: fatal error: libspotify/api.h: Datei oder Verzeichnis nicht gefunden
   #include "libspotify/api.h"
            ^~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pyspotify
  Running setup.py clean for pyspotify
Failed to build pyspotify
Installing collected packages: pyspotify, Mopidy-Spotify
  Running setup.py install for pyspotify ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-q3bwqnov/pyspotify/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-rjp9auh0/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.7
    creating build/lib.linux-armv7l-3.7/spotify
    copying spotify/user.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/playlist_track.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/offline.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/compat.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/error.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/eventloop.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/inbox.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/connection.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/sink.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/artist.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/config.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/link.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/toplist.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/playlist_container.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/session.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/image.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/social.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/__init__.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/playlist_unseen_tracks.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/album.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/playlist.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/_spotify_build.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/version.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/search.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/player.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/utils.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/track.py -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/audio.py -> build/lib.linux-armv7l-3.7/spotify
    running egg_info
    writing pyspotify.egg-info/PKG-INFO
    writing dependency_links to pyspotify.egg-info/dependency_links.txt
    writing requirements to pyspotify.egg-info/requires.txt
    writing top-level names to pyspotify.egg-info/top_level.txt
    reading manifest file 'pyspotify.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*' under directory '.github'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'examples/tmp'
    warning: no previously-included files matching '__pycache__/*' found anywhere in distribution
    writing manifest file 'pyspotify.egg-info/SOURCES.txt'
    copying spotify/api.h -> build/lib.linux-armv7l-3.7/spotify
    copying spotify/api.processed.h -> build/lib.linux-armv7l-3.7/spotify
    running build_ext
    generating cffi module 'build/temp.linux-armv7l-3.7/spotify._spotify.c'
    creating build/temp.linux-armv7l-3.7
    building 'spotify._spotify' extension
    creating build/temp.linux-armv7l-3.7/build
    creating build/temp.linux-armv7l-3.7/build/temp.linux-armv7l-3.7
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c build/temp.linux-armv7l-3.7/spotify._spotify.c -o build/temp.linux-armv7l-3.7/build/temp.linux-armv7l-3.7/spotify._spotify.o
    build/temp.linux-armv7l-3.7/spotify._spotify.c:540:10: fatal error: libspotify/api.h: Datei oder Verzeichnis nicht gefunden
     #include "libspotify/api.h"
              ^~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-q3bwqnov/pyspotify/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-rjp9auh0/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-q3bwqnov/pyspotify/

This is covered in the extension documentation.

Mopidy-Spotify has some non-python dependencies so if you want to install it using pip you must first install those dependencies. More info is provided in the Mopidy-Spotify readme.

Alternatively, and far simpler, is to install from mopidy.apt.com using sudo apt install mopidy-spotify.

apt install mopidy-spotify works for me
Thank you