How to compile Python code in Sublime Text 3 running on the Linux operating system?

Asked

Viewed 12,885 times

1

I’m editing the question to better explain what my question was.


I am a linux user and am starting web projects in Python. Soon I made use of the text editor, Sublime text 3, but it has a problem to execute Python code, being paralyzed or only compiling the first snippet of code.

I believe this problem has happened to many users, so I ask the question:

How to run or compile Python code in Sublime Text 3?

But the question was still confused, because my wish was to emulate the Python code on the console that exists inside Sublime.

However I was unsuccessful, until I did research on foreign sites and really understand that this is a failure of the editor that presents itself in different ways, be it in Windows, Linux or macOS.

  • You would have some problem compiling the code directly on the terminal?

2 answers

0

You need to indicate the location of your Python for Sublime Text 3, since Sublime Text is an editor and lacks the strength to compile or interpret programs.

Go to the Sublime Text menu and take the following steps:

Tools<Build System<New Build System

It will open an edit space inside your Sublime Text 3, there paste the following code:

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

Then save as the name you want - that name will appear on your build system.

That part /home/maquiavel/anaconda3/bin/python3 varies from user to user, if you are using Windows might be C:\\python27\\python.exe

Staying:

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

So locate your python directory and paste the path into the cmd

0


After a few hours of intense searching, I discovered one and more ways to solve this problem. Although it was not the solution that preferred, but solved the problem and added new features. Follow the youtube link:

"Sublime Text 3 for python developers" 1

"Configuring python terminal in sublime text 3" 2

Good luck to those in need!!!

  • Look at this question: https://answall.com/questions/175788

  • Opa Aercio, vlw guy but I ended up finding in foreign sources how to solve. But the solution is almost the same, the difference that I use the "anaconda" continuum package as a python interpreter, rather than the python of my own linux.

  • Understood, your system is linux, the question is Windows! (Y)

  • 1

    I suggest you read: https://pt.meta.stackoverflow.com/questions/42/queremos-respostas-que-contenham-somente-links/47#47 to avoid a negative score on your answers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.