question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get_exercise: invalid literal for int() with base 10: ''

See original GitHub issue

When I attempt to use the get_exercise code, I get the following error.

>>> import myfitnesspal
>>> client = myfitnesspal.Client('********', '********')
>>> client.get_exercise(2017,9,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "myfitnesspal\client.py", line 432, in get_exercise
    exercise = self._get_exercise(document)
  File "myfitnesspal\client.py", line 381, in _get_exercise
    value = self._get_numeric(column.text)
  File "myfitnesspal\client.py", line 220, in _get_numeric
    return int(re.sub(r'[^\d.]+', '', string))
ValueError: invalid literal for int() with base 10: ''

I believe it’s related to the fact that my iPhone syncs my step data in and returns N/A for minutes, which means that the re.sub… in _get_numeric is returning an empty string to int()

I can fix this, but I already have a pull request open and I’m unsure semantically if it makes more sense to check in _get_numeric and return 0 for blank strings or whether the get_exercise should be parsing for entirely non-numeric content before calling _get_numeric

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
coddingtonbearcommented, Feb 28, 2018

Released @jgissend10’s fix as part of 1.11.0; sorry for the delay!

1reaction
coddingtonbearcommented, Feb 26, 2018

Ahh; hrm – sorry about that; I’ll push out a new release later today!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: invalid literal for int() with base 10: '' - Stack Overflow
ValueError: invalid literal for int() with base 10: '' · 2. For anyone currently looking here. The error may be that one of...
Read more >
ValueError: invalid literal for int() with base 10
The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that's not an...
Read more >
ValueError: invalid literal for int() with base 10 in Python
The Python "ValueError: invalid literal for int() with base 10" occurs when we pass a string that cannot be directly converted to an...
Read more >
Python ValueError: invalid literal for int() with base 10
This error can frequently occur when converting user-input to an integer-type using the int() function. This problem happens because Python stores the input...
Read more >
Python ValueError: invalid literal for int() with base 10 Solution
Our error message tells us there is an invalid literal for an integer in base 10. This means the value we have passed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found