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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

So far so good, but how do I "change [my] .sublime-build file"?
Actually this one gives the instructions on how to change the sublime-build setting stackoverflow.com/a/23790095/2779792
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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.