can someone tell me what's wrong with my code? I am building a voice assistant for Spotify. I have made two .py files, one holds all the 'get uri' and 'play track' functions, and the other is used to authorize access using the client ID, Client Secret, and scope fetched from the Spotifys' developer forum by creating an app. Moreover, I have provided my PC's name as the device name and, the redirect uris. When running the main file, it is throwing a KeyError with context to the client ID. Here's the code:
import pandas as pd
from speech_recognition import Microphone, Recognizer, UnknownValueError
import spotipy as sp
from spotipy.oauth2 import SpotifyOAuth
from Spots import spotsFunctions as sf, InvalidSearchError
# Set variables from setup.txt
setup = pd.read_csv('userDetails.txt', sep='=', index_col=0, header=None).squeeze()
clientID = setup['clientID']
clientSecret = setup['clientSecret']
deviceName = setup['deviceName']
redirectUri = setup['redirectUri']
scope = setup['scope']
username = setup['username']
# Connecting to the Spotify account
auth_manager = SpotifyOAuth(
client_id = clientID,
client_secret=clientSecret,
redirect_uri=redirectUri,
scope=scope,
username=username)
spotify = sp.Spotify(auth_manager=auth_manager)
And the error it's throwing:
File "D:\Spotify Voice Assistant\venv\lib\site-packages\pandas\core\indexes\base.py", line 3800, in get_loc
return self._engine.get_loc(casted_key)
File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
File "pandas\_libs\hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas\_libs\hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'clientID'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Spotify Voice Assistant\main.py", line 11, in <module>
clientID = setup['clientID']
File "D:\Spotify Voice Assistant\venv\lib\site-packages\pandas\core\series.py", line 982, in __getitem__
return self._get_value(key)
File "D:\Spotify Voice Assistant\venv\lib\site-packages\pandas\core\series.py", line 1092, in _get_value
loc = self.index.get_loc(label)
File "D:\Spotify Voice Assistant\venv\lib\site-packages\pandas\core\indexes\base.py", line 3802, in get_loc
raise KeyError(key) from err
KeyError: 'clientID'