TiesdeKok / ipystata

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

[Errno 2] No such file or directory: 'log_output.log' #1

Closed roblem closed 9 years ago

roblem commented 9 years ago

My code is as follows:

import ipystata

on first time run, I set the stata path:

from ipystata.ipystata_magic import iPyStata
iPyStata.config_stata('/opt/stata/stata-mp') 

Then I attempt the simple command for testing connection

%%stata

display "I am running in Stata"

and I get the following error message:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-13-2cbc2dedc4d8> in <module>()
----> 1 get_ipython().run_cell_magic(u'stata', u'', u'\ndisplay "I am running in Stata"')

/home/roblem/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2262             magic_arg_s = self.var_expand(line, stack_depth)
   2263             with self.builtin_trap:
-> 2264                 result = fn(magic_arg_s, cell)
   2265             return result
   2266 

/home/roblem/anaconda/lib/python2.7/site-packages/ipystata/ipystata_magic.pyc in stata(self, line, cell, local_ns)

/home/roblem/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc 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):

/home/roblem/anaconda/lib/python2.7/site-packages/ipystata/ipystata_magic.pyc in stata(self, line, cell, local_ns)
    174 
    175         sleep(1)
--> 176         out = iPyStata.process_log('log_output.log')
    177 
    178         if args.output:

/home/roblem/anaconda/lib/python2.7/site-packages/ipystata/ipystata_magic.pyc in process_log(self, log)
     54 
     55     def process_log(self, log):
---> 56         with open(log) as f:
     57             code = f.read()
     58         code = re.sub("\\n\. ..*?\\n", "\n", code)

IOError: [Errno 2] No such file or directory: 'log_output.log'

Perhaps this is a permissions issue?

I am running this on

Fedora 22 (using Anaconda Python 2.7) and have these versions of Ipython/Ipython Notebook installed: ipython 3.2.0 py27_0
ipython-notebook 3.2.0 py27_0

roblem commented 9 years ago

I had to change line 167 of ipystata_magic.py from

     cmd = [stata, '/e', "do", 'code.do']

to

     cmd = [stata, "do", 'code.do']
TiesdeKok commented 9 years ago

Sorry for my late response, I am currently a bit busy. Awesome that you managed to fix it yourself! I never tried my code on a non-Windows machine, so I suspect that is where the problem comes from.

lan-slot commented 1 year ago

I had to change line 167 of ipystata_magic.py from

     cmd = [stata, '/e', "do", 'code.do']

to

     cmd = [stata, "do", 'code.do']

Hi, I met this problem, may I ask how to fix it now? there is no such code in new version ipystata 'line 167 of ipystata_magic.py' right now.