mattiasnordin / StataEditor

Stata Editor for Sublime Text 3
47 stars 18 forks source link

Code not passing to Stata #8

Closed gautambastian closed 8 years ago

gautambastian commented 8 years ago

Hello Matt,

I am brand new to using Stata Editor. I set up the Stata Automation using the Vista instructions as you suggest. When I try to "do" or "run" my do file, an instance of Stata opens but the code doesn't pass through. When I "do" or "run" again another instance of Stata opens, with the same result.

I'm using Stata 13.1.

Any advice?

mattiasnordin commented 8 years ago

I'm not sure what the issue could be. Have you installed the Pywin32, if not, that will probably do it. Otherwise, when you run code, open the console and see if you get an error message there.

theodorius123 commented 8 years ago

That sounds like faulty Stata Automation. I had exactly the same on my laptop cause I forgot to run it as an admin. Maybe you should try again and check if you really do all the steps.

gautambastian commented 8 years ago

Thanks both!

I'll try again. Is there a prompt message or some way to check and make sure that Stata Automation has been activated?

I have Pywin32 installed. I get the following output in the console, which includes error messages toward the bottom:

reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin StataEditor.CompletionsPlugin
Pywin32: Added 'win32'
Pywin32: Added 'win32/lib'
Pywin32: Added 'win32com'
Pywin32: Added 'win32comext'
reloading plugin StataEditor.StataEditorPlugin
reloading plugin Pywin32.setup
plugins loaded
indexing [queue 1]: no files were indexed out of the 939 queued, abandoning crawl
unable to auto detect encoding for C:\Users\*****\Box Sync\GIL2-EthiopiaWALN\06Analysis\ML\Do\Analysis for ML report.do, using fallback encoding Western (Windows 1252)
Package Control: Skipping automatic upgrade, last run at 2016-03-08 17:16:30, next run at 2016-03-08 18:16:30 or after
indexing [queue 2]: no files were indexed out of the 939 queued, abandoning crawl
indexing [queue 4]: no files were indexed out of the 919 queued, abandoning crawl
Unable to open /C/Users/*****/AppData/Roaming/Sublime Text 3/Packages/StataEditor/StataEditor.sublime-settings
indexing [queue 8]: no files were indexed out of the 49 queued, abandoning crawl
Traceback (most recent call last):
  File "StataEditorPlugin in C:\Users\*****\AppData\Roaming\Sublime Text 3\Installed Packages\StataEditor.sublime-package", line 21, in StataAutomate
AttributeError: 'module' object has no attribute 'stata'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\*****\AppData\Roaming\Sublime Text 3\Packages\Pywin32\lib\x64\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 568, in run_
return self.run(edit, **args)
  File "StataEditorPlugin in C:\Users\*****\AppData\Roaming\Sublime Text 3\Installed Packages\StataEditor.sublime-package", line 84, in run
  File "StataEditorPlugin in C:\Users\*****\AppData\Roaming\Sublime Text 3\Installed Packages\StataEditor.sublime-package", line 25, in StataAutomate
  File "C:\Users\*****\AppData\Roaming\Sublime Text 3\Packages\Pywin32\lib\x64\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Users\*****\AppData\Roaming\Sublime Text 3\Packages\Pywin32\lib\x64\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Users\*****\AppData\Roaming\Sublime Text 3\Packages\Pywin32\lib\x64\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
indexing [queue 9]: no files were indexed out of the 49 queued, abandoning crawl
mattiasnordin commented 8 years ago

My guess would also be that it is something that has gone wrong with the creation of the automation object. I believe you could check if it's working by opening the console and write: import win32com.client win32com.client.Dispatch ("stata.StataOLEApp") If it launches Stata, automation should be working.

gautambastian commented 8 years ago

Thanks again Mattias! Indeed, the automation object was not properly installed. I had to log in as administrator and then follow the instructions on the Stata website for Vista. "Run as administrator" from within a non-administrator user profile wasn't sufficient.

Works beautifully now!

mattiasnordin commented 8 years ago

Great!