1

I am using Python 3.4 and Sublime Text 3 in a Windows 7 machine.

If I go to the cmd prompt and type

python 

I get

'python' is not recognized as an internal or external command...

If I type

py

It works and I get

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

When I use the Sublime 3 build command it issues the command

python -u "C:\Whatever\MyPythonFile.py"

Which does not work. Apparently I need Sublime Text 3 to use the command 'py' instead of 'python' when building.

What are the exact steps I need to take to change Sublime Text 3 to get it to run python scripts in my environment using the build command?

I have been searching for quite a while and all I can find are instructions on how to add the python directory to PATH, which does not seem to be my problem.

Matthew James Briggs
  • 2,085
  • 2
  • 28
  • 58

1 Answers1

5

With Sublime Text 3, packages are zipped up in .sublime-package archives, making them invisible to you. Luckily, there is a package you can download to work around this:

  1. Download Package Resource Viewer using Package Control.

  2. ctrl + shift + P, type PRV and click Extract Package. Extract the Python package.

  3. Preferences -> Browse Packages. Your Python folder should be here now. Open it, find Python.sublime-build.

  4. Now, I'm not 100% positive on this part, because I've never heard of this problem you're having, but you should be able to change your .sublime-build file as follows:

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

This should run it with py -u "C:\Whatever\yourFile.py" if I'm not mistaken.

Community
  • 1
  • 1
maccartm
  • 2,035
  • 14
  • 23
  • So far so good, but how do I "change [my] .sublime-build file"? – Matthew James Briggs Jun 24 '15 at 23:27
  • Actually this one gives the instructions on how to change the sublime-build setting http://stackoverflow.com/a/23790095/2779792 – Matthew James Briggs Jun 24 '15 at 23:32
  • By the way, this did solve my python build problem which is very strange because search results seem like I'm the first person in the history of the Internet to have this issue. All I did was install Python, install Sublime Text 3, and boom, it didn't work. – Matthew James Briggs Jun 24 '15 at 23:43
  • Sorry I've been away for a bit, I'm assuming you figured it out but essentially you just open up the `.sublime-build` file as a text file or with sublime or whatever you feel like doing and change the `"cmd"` line to `["py", "-u", "$file"],`, for anyone interested. – maccartm Jun 25 '15 at 00:00