Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding issue when trying to run soccer collect py file #1

Closed
ladams81 opened this issue Feb 4, 2015 · 5 comments
Closed

Encoding issue when trying to run soccer collect py file #1

ladams81 opened this issue Feb 4, 2015 · 5 comments

Comments

@ladams81
Copy link

ladams81 commented Feb 4, 2015

When i try and run collect_fantasysoccer it threw the following error below

SyntaxError: Non-ASCII character '\xc2' in file collect_fantasysoccer.py on line 415, but no encoding
declared; see http://www.python.org/peps/pep-0263.html for details

I then added the following line to the py file

#coding=UTF-8

Tried to run again, this time it got further but resulted in the following error below

Getting general statistics from https://www.dreamteamfc.com/statistics/players/ALL/ ...
Getting team standings from http://www.espnfc.com/barclays-premier-league/23/table ...
collect_fantasysoccer.py:197: UnicodeWarning: Unicode unequal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
res = [i.text for i in td.next_siblings if isinstance(i, bs4.element.Tag) and i.text!='\xa0']
Traceback (most recent call last):
File "collect_fantasysoccer.py", line 528, in
epl_data.get_all()
File "collect_fantasysoccer.py", line 41, in get_all
self.get_team_standings()
File "collect_fantasysoccer.py", line 199, in get_team_standings
values = [int(i) for i in res[1:]]
ValueError: invalid literal for int() with base 10: ''

Could you advise me as to how to get around this?

Appreciated

@rasbt
Copy link
Owner

rasbt commented Feb 4, 2015

I am sorry about this issue. One quick question: Are you using Python 2.7 or 3.4? I only tested it with 3.4 - since I've always had issues with unicode in Python 2.7 I typically only use Python 3.4 for such things.

@ladams81
Copy link
Author

ladams81 commented Feb 4, 2015

Hi there.

Thanks for the swift response. Im using Python 2.7. Its probably the default one installed with this mac.

Okay thanks I'll try python 3.4 and let you know.

@rasbt
Copy link
Owner

rasbt commented Feb 4, 2015

You are welcome, and thanks for bringing this up, I will add a note about Python 3 usage to make life easier for other users :).
Yes, Python 2.7 is the default for Mac OSX. In general, I wouldn't recommend using the default (system's) python version. If you are about to install a "new" Python version, have a look at Anaconda. It's a free Python distribution that makes the usage of virtual environments and installation of most major libraries (and updating them) really easy and convenient (especially the compiled stuff like NumPy, SciPy etc.). Most people that I know are using it :)
https://store.continuum.io/cshop/anaconda/

@ladams81
Copy link
Author

ladams81 commented Feb 4, 2015

Hi there.

Thanks for the info. Upgrading to Python 3 did rectify the issue for me.

Cheers

@rasbt
Copy link
Owner

rasbt commented Feb 4, 2015

Nice, I am glad to hear! Especially when it comes to text (and "exotic" characters), Python 3 makes life a lot easier ;)

@rasbt rasbt closed this as completed Feb 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants