Skip to content

Diagnosing errors

rpguiteras edited this page Jan 18, 2024 · 4 revisions
  1. If a statacons error is the result of a Stata do-file exiting with error, a .log file will be saved, typically to the directory from which you are running statacons. Examine this .log file to see if the error seems to be with the Stata code rather than with SCons or statacons per se.

  2. Exit and re-start all instances of Stata, Python, Anaconda, etc.

  3. Verify that all programs (ado-files and other) are up-to-date, that you are in fact using the ado-files that you think you are, and that Stata can find Python, SCons and pystatacons. In Stata:

    sysdir
    which statacons
    python query
    python which SCons
    python which pystatacons
  1. Because the mechanics of statacons are a bit complex (Stata calls Python, which loads SCons and pystatacons, then calls SCons, which then calls Stata in batch mode), it can be difficult to see exactly where an error is occurring. To attempt to isolate the problem:

    1. Check that your code runs in Stata (do code/dofile.do as usual from within Stata).
    2. Check whether your code runs in Stata's batch mode from your terminal of choice (e.g., "C:\Program Files\Stata16\StataSE.exe" /e do "code/dofile.do").
    3. Look at the output of statacons, show_config to see whether statacons is finding Stata properly, etc. If you obtain surprising results from statacons, show_config, examine config_local.ini and config_project.ini to see if you are setting any variables incorrectly.
    4. Run scons from a terminal. Conditional on arriving to this step without error, if you see an error here, it is likely related to SCons itself (e.g., the SConstruct script) rather than statacons per se. If you do not see an error in command-line scons, but the error persists when invoking statacons from within Stata, then the error is related to either the statacons command or the way that Stata interacts with Python and SCons.
  2. Run debugging-checklist.do and inspect the output carefully.

Clone this wiki locally