[SUPPORT] An exception has occurred, use %tb to see the full traceback. SystemExit: 2
vilut opened this issue · 6 comments
Hello,
Firstly let me thank you for making this code available for everyone. As a non-computer scientist runner, I have wished many times before I had the skills to actually do what you did. As of now I have a Garmin watch that easily connects with strava, but I still have 2 years of runs in my phone in the Huawei health app that I would appreciate to have on strava and check my progress since 2017.
Anyway, I have been having trouble using your code. I have had multiple problems, I have solved most, but as of now I still don't have the output files. I don't have any errors shown in the command line when I run everything as you suggested here in github (see picture attached). However, when I open your .py file in spyder and run it, I get this error:
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
Besides, I am assuming the output file would go to the folder where the .py file and the .zip files are, right?
I know it is not much to go on, but I am happy to give you more information.
Thank you very much for your help in advance
Thanks for your kind words and sorry to hear the script doesn't work (yet) for you.
Let's start with verifying the python (development language) installation first as follows:
- Open a command prompt (click on the Windows start menu icon and type cmd and press the enter key).
- In the opened command prompt window (like the one of your screenshot above), type python
If all is well you should see something like:
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Hitrava is tested on the 3.7.6 version, I recommend to use at least this version.
If you would have an older version, please have a look at the 'Installation' section in the README.md file of the project on how to install Python.
If you're not sure, just post back the version information you see.
Do I understand correct that you tried to run the script from a Spyder Development Environment and you got the error from that environment? If Python is installed correctly, there shouldn't be any need for a development environment.
You say you solved some other issues earlier. Do you mean installation issues or did you need to make changes to the code?
Hope we can sort this out.
Just thought of something else. From your screenshot, it looks like the script ran successfully, but maybe there was no data.
Could you open the ZIP file you received from Huawei (HiZip.zip) and check if the health data file is in there and what it's size is?
You should look for either of the files below in the ZIP file
data/Motion path detail data & description/motion path detail data.json
Motion path detail data & description/motion path detail data.json
If the file is there, it's size should be multiple megabytes. If it isn't there at all or if it has a very small size, chances are your request from the Huawei Health app didn't include the Health data. I noticed lately that their user interface for selecting the data is missing the check boxes. I clicked on 'Select All' on top of the list to make sure I had the Health data selected in the request.
Thank you for the step by step instructions!
Picture attached for the result of the version, as it contains a little more information than you predicted because of the anaconda, but the version is the same as yours (3.7.6).
I tried Spyder because I didn't have anything to go on and I tried what I could before contacting you. I had anaconda installed from about 2 years ago when I tried to learn a little Python for a personal project. But that was Python 3.6 back then. I tried to run through the command line and I didn't see any output so I noticed something was wrong. Run the code through spyder and I had a library missing (xmlschema). Tried to solved it, failed to do it. Uninstalled anaconda and reinstalled (now the 3.7.6 version) and now I had a .dll file missing. Managed to solve it, back to the xmlschema and then I managed to install it through Spyder and here I am! Every time I tried to run the code, I tried through the command line, spyder and at some point, I decided to download Python (following your suggestion of installation of Python) and starting running the same code there. I know that I am probably running the same thing using three similar programs, but I don't know much about programming and thought that after getting the output file from any try, I could simply uninstall all these programs. So, and also replying to your question, I haven't changed the code because it wouldn't go well...
As for the zip file, after unzipping it, it contains 4 folders, with a total of 29.6 MB. Names of the four folders:
- Health data & description
- Health detail data & description
- Motion path detail data & description
- Sport per minute merged data & description
Under Motion path detail data & description, there's your .json file. Tried to open it and it could be what your looking for. Here's the beginning of the content:
[{"motionPathData":[{"sportType":4,"totalTime":4546000,"totalSteps":12623,"timeZone":"+0000","deviceCode":103527906,"paceMap":{"30000407":281.0,"50000708":307.0,"80001165":303.0,"40000555":302.0,"149102215":304.0,"20000268":291.0,"10000127":329.0,"140002077":313.0,"60000865":315.0,"90001315":301.0,"100001473":317.0,"70001014":298.0,"120001778":287.0,"110001635":326.0,"130001927":299.0},"totalCalories":925000,"version":1523118146379,"partTimeMap":{"14.0":4269.0,"13.0":3956.0,"1.0":329.0,"2.0":620.0,"12.0":3657.0,"11.0":3370.0,"3.0":901.0,"10.0":3044.0,"4.0":1203.0,"5.0":1510.0,"6.0":1825.0,"7.0":2123.0,"8.0":2426.0,"9.0":2727.0},"location":[{"name":"gps point is in attribute HW_EXT_TRACK_DETAIL,not here"}],"startTime":1511105819000,"attribute":"HW_EXT_TRACK_DETAIL@istp=lbs;k=994;lat=39.4700711;lon=-8.5366936;alt=0.0;t=1.511107904E12;\ntp=lbs;k=598;lat=39.4807777;lon=-8.5415968;alt=0.0;t=1.51110711E12;\ntp=lbs;k=687;lat=39.4780172;lon=-8.5464815;alt=0.0;t=1.511107288E12;\ntp=lbs;k=1459;lat=39.4778493;lon=-8.5470588;alt=0.0;t=1.511108837E12;\ntp=lbs;k=71;lat=39.4745;lon=-8.548584;alt=0.0;t=1.511106037E12;\ntp=lbs;k=379;lat=39.4741414;lon=-8.5327072;alt=0.0;t=1.511106666E12;\ntp=lbs;k=731;lat=39.4772313;lon=-8.5492579;alt=0.0;t=1.511107377E12;\ntp=lbs;k=1124;lat=39.4738808;lon=-8.5325724;alt=0.0;t=1.511108164E12;\ntp=lbs;k=1720;lat=39.4707476;lon=-8.5390075;alt=0.0;t=1.511109362E12;\ntp=lbs;k=1282;lat=39.4811249;lon=-8.5368131;alt=0.0;t=1.511108482E12;\ntp=lbs;k=283;lat=39.4690247;lon=-8.5349261;alt=0.0;t=1.51110647E12;\ntp=lbs;k=144;lat=39.4733518;lon=-8.5432946;alt=0.0;t=1.511106183E12;\ntp=lbs;k=1312;lat=39.4820276;lon=-8.5386235;alt=0.0;t=1.511108542E12;\ntp=lbs;k=177;lat=39.4728304;lon=-8.5411409;alt=0.0;t=1.511106249E12;\ntp=lbs;k=356;lat=39.4728012;lon=-8.5324189;alt=0.0;t=1.51110662E12;\ntp=lbs;k=1781;lat=39.4689356;lon=-8.5348794;alt=0.0;t=1.511109484E12;\ntp=lbs;k=1262;lat=39.4801546;lon=-8.5359201;alt=0.0;t=1.511108442E12;\ntp=lbs;k=67;lat=39.4745674;lon=-8.5488755;alt=0.0;t=1.511106029E12;\ntp=lbs;k=830;l
Thank you so much for replying and helping, hope we can sort this out.
The good news: your ZIP file is perfectly fine and contains the required data.
I think (but I'm not an expert here) the (ana)conda python version might be the issue.
What I suggest is to install the default python version and create a copy of the default Run_Hitrava.cmd batch file to specifically use that default python interpreter. Follow the steps below:
- Install the default python version as explained in the Installation section in the README.md file (will install in parallel to your conda version I think) . When you install the latest 3.7 version to the default path as the user from your previous screenshots, you should find the python executable (python.exe) in the following folder:
C:\Users\ferna\AppData\Local\Programs\Python\Python37
- Make a copy of the Run_Hitrava.cmd in your Hitrava installation folder to e.g. my_run_hitrava.cmd
- Open the my_run_hitrava.cmd in notepad and change the first line so it explicitly points to the installed python version from the first step.
C:\Users\ferna\AppData\Local\Programs\Python\Python37\python.exe Hitrava.py --zip HiZip.zip --json_export
- Save the changes to my_run_hitrava.cmd in notepad.
- Run the my_run_hitrava.cmd
If you have any questions or problems, just let me me know.
I have solved the problem!
I have re-read your readme file and noticed something strange: When you first suggested a command to write in the command line, you suggest this: "Hitrava.py --zip HiZip.zip --json_export". However, below in usage examples, all commands include python in the beginning, before the .py file. So, I tried the first command with python before the Hitrava.py: "python Hitrava.py --zip HiZip.zip --json_export". And it worked like a charm. As you suggested to run the file in the command line, I am assuming that it is necessary to write python before the command. However, it beats me why in Python command line (if I can call it like that) I need to write python before. Or why I can't run the file in Spyder and get the output. Anyway, it is solved! If you let me, I would like to suggest you two things to improve:
- Replace "Hitrava.py --zip HiZip.zip --json_export" by "python Hitrava.py --zip HiZip.zip --json_export" in your readme file.
- If it is possible and it doesn't trouble you a lot, it would have been helpful to have the output files numbered. I have found a way to go around, but adding almost 300 files manually to strava is quite a lot and one can easily make a mistake by trying to add the same file twice. Truth be told, I blame Strava for this one, not you. But if the files were numbered, it would be easier to select them (1-25, 26-50, 51-75) and go around this issue. Just a suggestion that might help people with an even larger number of activities to upload manually.
Thank you very much for creating this code and replying to my support request.
Good to hear it worked out!
- As to your first question, the script contains what is called a 'shebang' to look for the default python 3 interpreter on your system. So, typically, adding or removing python at the beginning shouldn't make a difference, although I recognize it did in your case apparently (or did you install the default python installation, since installing this should set the proper environment variables in Windows to point to the installation?). Anyway, it works.
- I like your suggestion to add a sequence number to the output files. Will see to add this feature.
I will close this ticket, glad to be of help.

