Commcare Sync Run Log errors

Please assist with the below Run log:

Please note, that the pip install --upgrade pyodbc didn't help.

2022-02-14 13:21:12,419 commcare_export.cli INFO CommCare Export Version 1.6.0

Traceback (most recent call last):

File "/usr/local/bin/commcare-export", line 8, in


File "/usr/local/lib/python3.8/site-packages/commcare_export/", line 348, in entry_point


File "/usr/local/lib/python3.8/site-packages/commcare_export/", line 140, in main


File "/usr/local/lib/python3.8/site-packages/commcare_export/", line 283, in main_with_args

writer = _get_writer(args.output_format, args.output, args.strict_types)

File "/usr/local/lib/python3.8/site-packages/commcare_export/", line 212, in _get_writer

return writers.SqlTableWriter(output, strict_types)

File "/usr/local/lib/python3.8/site-packages/commcare_export/", line 338, in init

super(SqlTableWriter, self).__init__(db_url, poolclass=poolclass)

File "/usr/local/lib/python3.8/site-packages/commcare_export/", line 266, in init

self.engine = engine or sqlalchemy.create_engine(db_url, poolclass=poolclass)

File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/", line 479, in create_engine

return strategy.create(*args, **kwargs)

File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/", line 87, in create

dbapi = dialect_cls.dbapi(**dbapi_args)

File "/usr/local/lib/python3.8/site-packages/sqlalchemy/connectors/", line 37, in dbapi

return __import__("pyodbc")

ModuleNotFoundError: No module named 'pyodbc'

As mentioned on the wiki you need to install pyodbc manually:

You need to run this command in you python environment: pip install pyodbc

1 Like

Hi Simon,

pyodbc was already installed. I even tried an upgrade, later a reinstall but still get the error even though my connection string is in the below format:


Thank you,

Are you sure you are running commcare-export in the same python environment where you installed pyodbc? You could run these commands to check:

> python --version
> commcare-export --version
> pip list

What operating system are you running on?

Hi Simon,

I'm working on Windows 10.

Yes, I can run Commcare-export on this machine using bash files. See below example of bash script:

But I get the mentioned pyodbc error when I try to run exports via the self-hosted version of the Commcare Sync app.

Thank you,

If the issue is with CommCare Sync then you need to make sure the odbc driver is installed in the CommCare Sync python environment.

Depending on how you've installed CommCare Sync you would have created a virtual environment:

mkvirtualenv --no-site-packages commcare_sync -p $(which python3.8)

You would then need to make sure you install pyodbc into that environment:

pip install pyodbc

I tried the following, but the issue persists:

C:\Python39\Lib\venv\scripts\nt>pip install pyodbc

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at Release process - pip documentation v22.1.dev0 pip 21.0 will remove support for this functionality.

Requirement already satisfied: pyodbc in c:\python27\lib\site-packages (4.0.32)

Perhaps I should try to uninstall Python 2.7 but keep 3.9.

Perhaps I should try to uninstall Python 2.7 but keep 3.9.

I'd be surprised if CommCare Sync even supports 2.7. You should definitely be using a python version > 3.6.

How are you running CommCare Sync? We need to figure out which python env it is using so if you know what command you use to run it then we can work backwards from there.

I run the local Commcare Sync files using docker-compose up -d

Commcare Sync runs locally, but I get pyodbc error.

The issue comes when I run an export within Commcare Sync, with the following error: ModuleNotFoundError: No module named 'pyodbc'

Yet this module was successfully installed onto the C:\Python39 folder. I copied commcare sync git files onto the C:\Python39\commcare-sync folder.

I see you're using docker compose to run CommCare Sync which means it is using the python environment inside the docker container.

You'll need to update the docker container to include the pyodbc library. The easiest way to do this is to edit the requirements/requirements.txt file to include pyodbc. You will likely also need to make changes to the file to install the pyodbc dependencies: dockerfile - Connect docker python to SQL server with pyodbc - Stack Overflow

Alternatively you can run CommCare Sync directly on your machine by following the instructions here. Note that this setup is not recommended for production use but will work find for testing / dev environments.

For a production setup you should consider using the Ansible tooling provided: CommCare Sync Ansible’s Documentation — CommCare Sync Ansible documentation

Hi Simon,

I still get the Pyodbc module not found error. Is it right to have the below files and folders on the Python39 folder? Or should they be on another folder which sits on the Python39 folder?