mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #63] encode error #32
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @blackjack4494 on GitHub (Aug 20, 2015).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/63
Traceback (most recent call last):
File "playlist.py", line 30, in
print playlist['name']
File "C:\Python27\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2013' in position
11: character maps to
so u'\u2013' is a dash "-"
@CDeLeon94 commented on GitHub (Mar 28, 2019):
Same issue:
UnicodeEncodeError: 'charmap' codec can't encode character '\u0131' in position 2: character maps to <undefined>Particularly in my case when I try printing out a json response that contains this artist:
spotify:artist:1tcqeQAROtzEdmsNer8YXMThe
iI believe is the odd one, from looking up\u0131. A brief search yields a suggestion to check for the response's Unicode format and use the same thing when printing to stdout.@stephanebruckert commented on GitHub (Jan 17, 2020):
I couldn't reproduce it with the given artist. Please let me know if it happens again and share your code, not just the error. Also make sure you upgrade:
@bjobo commented on GitHub (Feb 9, 2020):
I get the same error, when I tried to fetch songs with a German 'Umlaut' (äöü). I'm using Python 3.4.2 (can't upgrade because it's bundeld with volumio).
Traceback (most recent call last): File "spotify_helper3.py", line 23, in <module> print(playlist['name']) UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 2: ordinal not in range(128)I used a code example from the documentation
`
import sys
import spotipy
import spotipy.util as util
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print("Whoops, need your username!")
print("usage: python user_playlists.py [username]")
sys.exit()
token = util.prompt_for_user_token(username)
if token:
sp = spotipy.Spotify(auth=token)
playlists = sp.user_playlists(username)
for playlist in playlists['items']:
print(playlist['name'])
else:
print("Can't get token for", username)
`
@stephanebruckert commented on GitHub (Feb 9, 2020):
Hey @bjobo can you please provide an artist ID or public playlist ID? thx
@bjobo commented on GitHub (Feb 10, 2020):
Example Track-ID: spotify:track:1dbd8HmdfD4BSIkIMoom3l
I tried it successfully on a different Raspberry Pi with Python 3.7.3 (default, Dec 20 2019, 18:57:59).
I don't know if the error results from using Python 3.4.2 (can't upgrade) or a wrong encoding. Any ideas?
@bjobo commented on GitHub (Feb 10, 2020):
After some testing I found out the problem is caused by the file system encoding:
If I set the env
export PYTHONIOENCODING=utf-8everything works fine. (However I don't know which other consequences it does have).Long story short: Ticket can be closed. It's not caused by Spotipy.