Error while converting app forms on macOS

Hello @jkuester
I am trying to convert app foprms on a macOS environment as seen below

cliff@cliffs-MacBook-Pro config % cht --url=https://medic:*****@cht.openelis-global.org convert-app-forms upload-app-forms
INFO Checking that https://medic:****@cht.openelis-global.org/medic/ is available... 
INFO Processing config in config. 
INFO Actions:
     - convert-app-forms
     - validate-app-forms
     - upload-app-forms 
INFO Starting action: convert-app-forms… 
INFO Converting form /Users/cliff/Documents/projects/mydhi-cht-config/config/forms/app/appointment.xlsx … 
/bin/sh: xls2xform-medic: command not found
INFO Error: There was a problem executing xls2xform.  It may not be installed.
E To install the latest pyxform, try one of the following:
E
E Ubuntu
E       sudo python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
E OSX
E       pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
E Windows (as Administrator)
E       python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic --upgrade
    at /usr/local/lib/node_modules/cht-conf/src/lib/convert-forms.js:79:20
    at async execute (/usr/local/lib/node_modules/cht-conf/src/lib/convert-forms.js:59:5)
    at async module.exports (/usr/local/lib/node_modules/cht-conf/src/lib/main.js:238:5)
    at async /usr/local/lib/node_modules/cht-conf/src/bin/index.js:16:5 
ERROR There was a problem executing xls2xform.  It may not be installed.
E To install the latest pyxform, try one of the following:
E
E Ubuntu
E       sudo python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
E OSX
E       pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
E Windows (as Administrator)
E       python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic --upgrade

According to the error above it recommends running pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic for OSX to fix the issue which i did a seen below

cliff@cliffs-MacBook-Pro config % pip3 install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
Defaulting to user installation because normal site-packages is not writeable
Collecting pyxform-medic
  Cloning https://github.com/medic/pyxform.git (to revision medic-conf-1.17) to /private/var/folders/_h/1b9xl77d0hn__qhbk5dbpbkw0000gn/T/pip-install-clpiqiql/pyxform-medic_1defb6008709460c8b3d840a4eee3058
  Running command git clone --filter=blob:none --quiet https://github.com/medic/pyxform.git /private/var/folders/_h/1b9xl77d0hn__qhbk5dbpbkw0000gn/T/pip-install-clpiqiql/pyxform-medic_1defb6008709460c8b3d840a4eee3058
  Running command git checkout -b medic-conf-1.17 --track origin/medic-conf-1.17
  Switched to a new branch 'medic-conf-1.17'
  branch 'medic-conf-1.17' set up to track 'origin/medic-conf-1.17'.
  Resolved https://github.com/medic/pyxform.git to commit 6f7909d564e104640562241da4cf8393036243ad
  Preparing metadata (setup.py) ... done
Requirement already satisfied: xlrd==1.0.0 in /Users/cliff/Library/Python/3.9/lib/python/site-packages (from pyxform-medic) (1.0.0)
Requirement already satisfied: unicodecsv==0.14.1 in /Users/cliff/Library/Python/3.9/lib/python/site-packages (from pyxform-medic) (0.14.1)
Requirement already satisfied: formencode in /Users/cliff/Library/Python/3.9/lib/python/site-packages (from pyxform-medic) (2.0.1)
Requirement already satisfied: unittest2 in /Users/cliff/Library/Python/3.9/lib/python/site-packages (from pyxform-medic) (1.1.0)
Requirement already satisfied: six in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (from formencode->pyxform-medic) (1.15.0)
Requirement already satisfied: traceback2 in /Users/cliff/Library/Python/3.9/lib/python/site-packages (from unittest2->pyxform-medic) (1.4.0)
Collecting argparse
  Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: linecache2 in /Users/cliff/Library/Python/3.9/lib/python/site-packages (from traceback2->unittest2->pyxform-medic) (1.0.0)
Installing collected packages: argparse
Successfully installed argparse-1.4.0

However when i run the command to convert the app forms in CHT i get the original error

ERROR There was a problem executing xls2xform.  It may not be installed.
E To install the latest pyxform, try one of the following:
E
E Ubuntu
E       sudo python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
E OSX
E       pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic
E Windows (as Administrator)
E       python -m pip install git+https://github.com/medic/pyxform.git@medic-conf-1.17#egg=pyxform-medic --upgrade

What do you see if you just run xls2xform-medic in the terminal? It seems like the installation was successful, but somehow maybe the command is not found on your PATH…

The other thing that I notice here is that I think you are using Python 3 (pip3), while Python 2.7 is the version recommended for pyxform-medic. But, I don’t have enough OSX/Python experience to know for sure if this could actually cause an issue…

@tlepiz can you share which Python version you are using on your OSX? (And/or if you have ever seen this issue before?)

cliff@cliffs-MacBook-Pro config %  xls2xform-medic
zsh: command not found: xls2xform-medic
cliff@cliffs-MacBook-Pro config %

thanks @jkuester

I think that I haven’t seen that error before. But my first idea was about the python version, as you point @jkuester, I might be wrong, not sure.

I am using python 2.* because when we migrated the enketo version I had errors because I was using python 3.*

~ python --version
Python 2.7.18
2 Likes

Thanks @tlepiz ,
So ideally the solution is to down grade to python 2 for now

I think so. (Though, FWIW on Linux I have in the past been able to have both Python 2 and Python 3 installed (and pyxform-medic installed on Python 2). That being said, I am no expert on Python or OSX, so this may or may not be possible for you…)

One alternative: if you happen to already be using Docker, you could try just running cht-conf in Docker. That should make it agnostic to whatever version of python you have on your local system…

2 Likes

I also have python 2 and 3 installed, and I set python 2 the default version to use

~ python --version
Python 2.7.18
~ python3 --version
Python 3.9.6
1 Like

hello @tlepiz @jkuester i added python2 using pyenv and it works…
Thanks

3 Likes