TiesdeKok / ipystata

Enables the use of Stata together with Python via Jupyter (IPython) notebooks.
192 stars 68 forks source link

python 3.5, ipython4.1, Mac OS, Stata 13, runnning error #3

Closed asdf8601 closed 8 years ago

asdf8601 commented 9 years ago

Hi,

I don't know if the path to executable is correctly, but when I try to run de example code I get a traceback:

In [1]: import ipystata

/Users/mmngreco/Virtualenvs/ipynb/lib/python3.5/site-packages/IPython/utils/path.py:264: UserWarning: get_ipython_cache_dir has moved to the IPython.paths module
  warn("get_ipython_cache_dir has moved to the IPython.paths module")

In [2]: from ipystata.ipystata_magic import iPyStata
In [3]: p = '/Applications/Stata/StataSE.app/Contents/MacOS/stata-se'
In [4]: iPyStata.config_stata(p)
In [5]: %%stata  
        display "Hello, I am printed in Stata." 
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-0d1a8dd6e7ba> in <module>()
----> 1 get_ipython().run_cell_magic('stata', ' ', 'display "Hello, I am printed in Stata." ')

/Users/mmngreco/Virtualenvs/ipynb/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2291             magic_arg_s = self.var_expand(line, stack_depth)
   2292             with self.builtin_trap:
-> 2293                 result = fn(magic_arg_s, cell)
   2294             return result
   2295 

/Users/mmngreco/Virtualenvs/ipynb/lib/python3.5/site-packages/ipystata/ipystata_magic.py in stata(self, line, cell, local_ns)

/Users/mmngreco/Virtualenvs/ipynb/lib/python3.5/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

/Users/mmngreco/Virtualenvs/ipynb/lib/python3.5/site-packages/ipystata/ipystata_magic.py in stata(self, line, cell, local_ns)
    183 
    184         sleep(1)
--> 185         out = iPyStata.process_log('log_output.log')
    186 
    187         if args.output:

/Users/mmngreco/Virtualenvs/ipynb/lib/python3.5/site-packages/ipystata/ipystata_magic.py in process_log(self, log)
     63 
     64     def process_log(self, log):
---> 65         with open(log) as f:
     66             code = f.read()
     67         code = re.sub("\\n\. ..*?\\n", "\n", code)

FileNotFoundError: [Errno 2] No such file or directory: 'log_output.log'
TiesdeKok commented 9 years ago

This error is most likely caused by the OS, I only tested it on Windows. Maybe it works if you add the argument "--openstata" (See the instructions on GitHub and issue #1)?

TiesdeKok commented 8 years ago

I am working on a version for Unix operating systems, see #6 for the progress. I will close this issue for now.