-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Installing IPyStata for Stata 14 64-bit on Windows 10 & Anaconda3 (64-bit) #39
Comments
import ipystata executes without error and the above error occurs after restarting the kernel |
C:\Program Files (x86)\Stata14>ls C:\Program Files (x86)\Stata14>StataMP-64.exe /Register C:\Program Files (x86)\Stata14> ran without error as the the import ipystata bit and restarting the kernel. get_ipython().run_cell_magic('stata', '-o car_df', 'sysuse auto.dta') still gives UsageError: Cell magic |
the same for me, anyone dealt with it? |
@huozi07 let's see if we can figure out what is wrong. Some questions:
|
stata installed, batch mode works |
@karajimys this is not necessarily a problem with ipystata, it is more likely a problem with win32 not being able to run/find Stata. I assume you get the same error if you run the below in a Jupyter Notebook? import win32com.client as win32
win32.Dispatch("stata.StataOLEApp") |
@TiesdeKok thank you for the answer. Yes exactly the same error. |
Ok, that implies that the register step wasn't successful. Did you try to follow the registration steps (https://www.stata.com/automation/#createmsapp) but with an elevated command prompt (i.e. right click on CMD and click "run as administrator")? |
This method solves my problem. It should be a user permission problem, and
thanks @TiesdeKok https://www.stata.com/automation/#createmsapp |
%%stata
display "Hello, I am printed in Stata."
produces
com_error Traceback (most recent call last)
C:\Users\Public\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
88 try:
---> 89 IDispatch = pythoncom.connect(IDispatch)
90 except pythoncom.ole_error:
com_error: (-2147221005, 'Invalid class string', None, None)
During handling of the above exception, another exception occurred:
com_error Traceback (most recent call last)
in
----> 1 get_ipython().run_cell_magic('stata', ' ', 'display "Hello, I am printed in Stata." \n')
C:\Users\Public\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
2356 with self.builtin_trap:
2357 args = (magic_arg_s, cell)
-> 2358 result = fn(*args, **kwargs)
2359 return result
2360
<C:\Users\Public\Anaconda3\lib\site-packages\decorator.py:decorator-gen-127> in stata(self, line, cell, local_ns)
C:\Users\Public\Anaconda3\lib\site-packages\IPython\core\magic.py in (f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
C:\Users\Public\Anaconda3\lib\site-packages\ipystata\ipystata_magic.py in stata(self, line, cell, local_ns)
318 time.sleep(0.5)
319 self.log_dict[session_id] = os.path.join(self.lib_dir, 'log%s.txt' % session_id)
--> 320 self.session_dict[session_id] = win32com.client.Dispatch("stata.StataOLEApp")
321 self.do_dict[session_id] = self.session_dict[session_id].DoCommandAsync
322 self.session_dict[session_id].UtilShowStata(1)
C:\Users\Public\Anaconda3\lib\site-packages\win32com\client_init_.py in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
93 """
94 assert UnicodeToString is None, "this is deprecated and will go away"
---> 95 dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
96 return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
97
C:\Users\Public\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
112 else:
113 userName = str(userName)
--> 114 return (_GetGoodDispatch(IDispatch, clsctx), userName)
115
116 def _GetDescInvokeType(entry, invoke_type):
C:\Users\Public\Anaconda3\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
89 IDispatch = pythoncom.connect(IDispatch)
90 except pythoncom.ole_error:
---> 91 IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
92 else:
93 # may already be a wrapped class.
com_error: (-2147221005, 'Invalid class string', None, None)
The text was updated successfully, but these errors were encountered: