Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using the pystata module in a Python executable

    I am sorry if this is a dumb question but my knowledge of the interface between Python and Stata is very limited. All of the documentation of pystata refers to calling Stata or Mata from an *interactive* Python environment (iPython). However, for a project that I am developing we would need to call Stata from a compiled Python script - i.e. an executable program - created using, for example, pyinstaller or py2exe. Is this possible? Or, alternatively, is it possible to mimic an interactive environment by running a python script on a regular schedule?

    There are two separate issues here. First, in a production environment I have concerns about the execution speed of interpreted Python for carrying out standard operations for very large numbers of cases, so I would rather rely on compiled code rather interpreted code. [As a side comment, this wouldn't matter if there was an interface between Julia and Stata/Mata.] Second, all of the code could eventually be written in Python but I would much rather rely on existing Stata/Mata functions to speed up development as well as being able to develop new models in parallel with the regular execution of existing code.

    It is possible that the references to interactive Python in the documentation is simply a matter of phrasing reflecting the usual assumption that Stata is used interactively by most people. I rely almost entirely on do-files or Python script files, so I find the constant reference to interactive use as rather alien. More important, the standard thing about creating executable files is the role of dependencies. I assume that pyinstaller could not bundle dependencies on Stata, so I am not sure how the executable program would handle calls to Stata.
Working...
X