0

hey guys im trying to make a new build for python 3 on sublime text 3. This is because none of my newly installed modules do not work. sklearn and lxml, and many others do not work with the shell interpreter. They give the message

    Traceback (most recent call last):
  File "/Users/saminahbab/Documents/Programming /machines/my own work /primer.py", line 1, in <module>
    from sklearn import datasets
ImportError: No module named sklearn
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u "/Users/saminahbab/Documents/Programming /machines/my own work /primer.py"]
[dir: /Users/saminahbab/Documents/Programming /machines/my own work ]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

despite the fact that sklearn now works in python3 commands in terminal. can someone tell me what to put in the new sublime build that I am about to make that will link up sublime to python correctly? im so lost and its confusing to see how python is linked with sublime, seeing as python 2.7 worked perfectly and now none of my libraries work,

EDIT this seems not to work with Pycharm either

MattDMo
  • 100,794
  • 21
  • 241
  • 231
entercaspa
  • 674
  • 2
  • 7
  • 19

1 Answers1

1

Your build system isn't working because it's calling python, not python3. You can create a new Python3.sublime-build file to correct this. Before you do, though, you'll need to find the path to your python3 binary by running this in Terminal:

which python3

Next, in Sublime, select Tools -> Build System -> New Build System and replace the contents with the following:

{
    "cmd": ["/path/to/python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell": true
}

replacing /path/to/python3 with the actual path printed by the which python3 command above.

Save the file as ~/Library/Application Support/Sublime Text 3/Packages/User/Python3.sublime-build (when hitting Save it should automatically be in the correct directory), and now you will have a Python3 option under Tools -> Build System. Select that option, and you should now be able to run Python 3 scripts with Sublime.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • thanks man this sorts it out! in the meantime ive been using pycharm which is a doddle with its intellij stuff and beautiful suggested formatting, but i miss the simplicity of sublime, I see whats goig on here and how it works, so thanks man, ill update the build on sublime and let you know.. also man do you know if there are any features similar to intellij autocorrect in sublime 3? – entercaspa May 20 '16 at 07:57