sijk/sublime-licence-snippets

ImportError: No module named 'Foundation'

lendle opened this issue · 2 comments

When trying to insert a snippet:

 File "/Users/sam/Library/Application Support/Sublime Text 3/Packages/Licence Snippets/Licence Snippets.py", line 18, in getuser
    import Foundation
ImportError: No module named 'Foundation'

No idea if this matters or not, since I saw somewhere that ST uses it's own version of python, but the python I am using is Enthought Canopy Python 2.7.3.

The problem seems to be that the module Foundation is only sometimes found or available on OSX. You may have to add it to your path or install the Foundation Framework. There does not seem to be an easy way to get a user's name on OSX. Licence Snippets uses the username to auto fill the licence. I don't have OS X available to test this but if you are willing replacing lines 18 and 19 with lines 24 and 25 in Licence Snippets.py might work.

That returns my login username which I can tab to and easily change, so that's nice.

Googling turned up this and I found that

return os.popen("finger `whoami` | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //'").read().rstrip('\n')

in place of lines 18 and 19 worked as expected.