I'm on Mac (version 16, 12 processor MP) and I would like to send email through Stata. I found the email package by William Buchanan, available on ssc, and have given it a shot but with no success. The help file indicates that it is compatible with Stata v 12.1 and requires Python 2.7. I looked at the ado file and there is a version command there so I don't think that is my problem.
Here is the out-of-the-box command I tried as a tester and the error, with the email addresses masked. I double checked the emails to make sure they were correct and they are. I know little to nothing about Python so I don't know how to understand the error
With the command being out-of-the-box, I recognize that something needed to change because Python 3.7 is what came with my Mac, not Python 2.7. So, I installed Python 2.7 using Homebrew. I can now run Python 2.7 from Terminal using the command python2. I tried editing the ado file in a similar way (i.e, python2 instead of python; there were two places where this was needed) so that the ado file would try to use the right version. After that edit, here is what I get...
So, here it seems that Stata is not even finding Python 2.7 even though I can run it from Terminal.
It will be plain to see that I'm woefully inadequate to deal with this problem...I don't understand Python and how Stata works with it enough to even know if I've framed the question in a sensible way.
Thanks for any insight.
Alternatively, does anyone have an approach to emailing from Stata on Mac that has worked for them? I used to do this routinely on PC but made the switch to Mac years ago.
Best,
Lance
Here is the out-of-the-box command I tried as a tester and the error, with the email addresses masked. I double checked the emails to make sure they were correct and they are. I know little to nothing about Python so I don't know how to understand the error
Code:
. email, from("[email protected]") to("[email protected]") subject("I hope...") body("...it works.") (note: file body.txt not found) Traceback (most recent call last): File "/var/folders/wt/xskz7sw51492dqs6jj0d_6dc0000gp/T//S_35247.000001.py", line 9, in <module> s = smtplib.SMTP('localhost') File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 256, in __init__ (code, msg) = self.connect(host, port) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 316, in connect self.sock = self._get_socket(host, port, self.timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py", line 291, in _get_socket return socket.create_connection((host, port), timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 575, in create_connection raise err socket.error: [Errno 61] Connection refused
Code:
. email, from("[email protected]") to("[email protected]") subject("I hope...") body("...it works.") (note: file body.txt not found) /bin/bash: python2: command not found
It will be plain to see that I'm woefully inadequate to deal with this problem...I don't understand Python and how Stata works with it enough to even know if I've framed the question in a sensible way.
Thanks for any insight.
Alternatively, does anyone have an approach to emailing from Stata on Mac that has worked for them? I used to do this routinely on PC but made the switch to Mac years ago.
Best,
Lance
Comment