kerno
kerno

Reputation: 187

Set PYTHONPATH in SublimeText2

I've been googling for the last hour trying to find an answer, and have tried everything I've come across.

I have a specific Python package (MailSnake) that, when I Build in SublimeText2, returns

ImportError: No module named mailsnake

I understand this is because SublimeText2 is running the builtin Python (version 2.6) and needs to have the PYTHONPATH set in user settings.

How do I correctly set the env path? This is what I currently have.

"path": "Users/Me/Library/Python/2.7",
"cmd": ["python2.7", "-u", "$file"],
"env":
{
    "PYTHONPATH": "Users/Me/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"
},    
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",    

Upvotes: 1

Views: 6245

Answers (1)

cyberbemon
cyberbemon

Reputation: 3200

Edit %APPDATA%\Sublime Text 2\Python\Python.sublime-build

Change content to:

{
    "cmd": ["C:\\python27\\python.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

on mac

 { 
   "cmd": ["/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7", 
   "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", 
   "selector": "source.python"       
 }

after you've done that try the following

import platform
print platform.python_version()

if successful this will compile the code and prints out 2.7.* your current version * in my case this would be 2.7.2

also, it looks like you may not have the mailsnake installed properly. so try the following

  • Download the zip
  • extract it into a folder
  • using cmd, navigate to that folder and then into python-mailsnake-master\python-mailsnake-master.

  • then in cmd type in python setup.py install and this should install mailsnake

    you should now be able to import it and use it

Upvotes: 1

Related Questions