jrfiedler / stata-kernel

Stata kernel for IPython/Jupyter
12 stars 4 forks source link

Kernel dying #1

Closed cschwem2er closed 9 years ago

cschwem2er commented 9 years ago

Hi,

thank you very much for this attempt to finally level up Stata "Do-Files" ;) I remember you also wrote a python package for Stata.

Unfortunately your version does not work for me at the moment. I can select the Stata kernel, but it dies as soon as the notebook opens and tries to load the Kernel. I tried this with iPython 3.2 and 4.0, my Stata Version is MP14 (x64). I also doubled checked my Automation object, which works just fine for ipystata.

Update: The problem was pretty simple: Python 3 incompatibility due to missing parentheses for a print statement. I sent you a pull request with the change and an updated source for the kernelbase import.

jhconning commented 9 years ago

I'm also having trouble on a Windows 64 machine with Stata 11 IC. The sample notebook loads in the browser but within a few seconds I have a dead kernel. Could it be that the kernel has to be adapted to the version of Stata? What setup(s) has this been tested under?

UPDATE: I've now got it working! In case it's of use to other relative newbies like myself, this is how I got it to work:

  1. Clone the github repo to your machine. Until his pull request is accepted, use @methodds fork as it contains his suggested patch to work with python3 (and I believe if you also add the line
 from __future__ import print_function 

to the top of the stata_kernel.py file the kernel should then in fact work with either python2 or 3).

  1. Apply the changes with a 'python setup.py install' from the command line.
  2. Now follow instructions for a Stata Automation object (I used instructions for a Vista machine).
  3. From the command line type 'ipython notebook' (or 'jupyter notebook') . You'll see Stata open up in the background when you open your first notebook.

Thanks for this kernel, This is huge!

One remaining question: what about plots? They don't seem to show up either in the notebook or in the parallel Stata session.

jrfiedler commented 9 years ago

Sorry for the delay. I probably should have put on the README that this was pretty experimental. I honestly didn't expect anyone to be using it yet.

I'll look over the pull request. Thanks for finding the problem.

jrfiedler commented 9 years ago

what about plots?

I haven't tried doing anything with plots yet. I believe Stata's plot windows are automatically hidden when Stata is being automated. One way to get graphs would be to insert a command into Stata to save the graph, then use Python code to insert the saved graph into the cell. I did something like that for a demo at the 2014 Stata Conference (pdf of presentation--see pages 30-36; code here, and more specifically here).

Hopefully I will have some time to work on plots soon.

jrfiedler commented 9 years ago

methodds, I see you forked the repo and made the change in your fork, but did you do a pull request? I don't see any.

cschwem2er commented 9 years ago

Hi, you should have received a PR now. I also added @jhconning 's suggestion for the future import. As for the plotting issue, maybe you could have a look at the solution in ipystata https://github.com/TiesdeKok/ipystata/issues/4

On a sidenote: although this might not be the best place to discuss this, but maybe working together with ipystata and @TiesdeKok would be a good idea anyway. Isn't it possible to combine your two approaches, so that one could choose between "stata only" mode and cell magics? This would be such a huge possibility for modern Stata use.

jrfiedler commented 9 years ago

Fixed in this pull request and subsequent commit 673d57faa4bc70650b3ee957e4e639aa5fa10de0