From ab2f52e81a16c6fd8968a044ea6e691e5f3da301 Mon Sep 17 00:00:00 2001 From: Shantanu Goel Date: Tue, 21 Mar 2017 18:38:39 +0530 Subject: [PATCH] Fix execution on headless systems where webbrowser module may not be present --- spotipy/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotipy/util.py b/spotipy/util.py index 102c462..5c51d9d 100644 --- a/spotipy/util.py +++ b/spotipy/util.py @@ -5,7 +5,6 @@ from __future__ import print_function import os from . import oauth2 import spotipy -import webbrowser def prompt_for_user_token(username, scope=None, client_id = None, client_secret = None, redirect_uri = None): @@ -67,6 +66,7 @@ def prompt_for_user_token(username, scope=None, client_id = None, ''') auth_url = sp_oauth.get_authorize_url() try: + import webbrowser webbrowser.open(auth_url) print("Opened %s in your browser" % auth_url) except: