Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zaemiel/4fbd8b5125fda7a140be to your computer and use it in GitHub Desktop.
Save zaemiel/4fbd8b5125fda7a140be to your computer and use it in GitHub Desktop.
@jreyes085
Copy link

Hi, can I user #!python3 or #!python2 in the first line of the py script to let Sublime which python build config to use?

@HabibRh26
Copy link

yes,you can,it works with diff version @jreyes085

@masiarek
Copy link

masiarek commented Feb 19, 2020

On windows (replace my user id 'masia' - with your user):

C:\Users\masia\AppData\Roaming\Sublime Text 3\Packages\User
{
"cmd": ["C:\Users\masia\AppData\Local\Programs\Python\Python38\python.exe", "-u", "$file"],
"file_regex": "^ ]File "(...?)", line ([0-9]*)",
"selector": "source.python"
}

@rudra-shukla
Copy link

thank you

@Kulu21
Copy link

Kulu21 commented Feb 29, 2020

Hi

I am trying this in Linux (LXLE), and get the following error message when trying the print(sys.version) command:

/usr/bin/python3: can't find 'main' module in ''
[Finished in 0.3s with exit code 1]
[cmd: ['python3', '-u', '']]
[dir: /opt/sublime_text]
[path:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

I would be really grateful if anyone could help me correct this.

Thanks in advance.

@zaemiel
Copy link
Author

zaemiel commented Feb 29, 2020

Hi

I am trying this in Linux (LXLE), and get the following error message when trying the print(sys.version) command:

/usr/bin/python3: can't find 'main' module in ''
[Finished in 0.3s with exit code 1]
[cmd: ['python3', '-u', '']]
[dir: /opt/sublime_text]
[path:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

I would be really grateful if anyone could help me correct this.

Thanks in advance.

"cmd": ["python3", "-u", "$file"],

@Kulu21
Copy link

Kulu21 commented Feb 29, 2020

Hi
I am trying this in Linux (LXLE), and get the following error message when trying the print(sys.version) command:
/usr/bin/python3: can't find 'main' module in ''
[Finished in 0.3s with exit code 1]
[cmd: ['python3', '-u', '']]
[dir: /opt/sublime_text]
[path:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
I would be really grateful if anyone could help me correct this.
Thanks in advance.

"cmd": ["python3", "-u", "$file"],

Hi

Thanks for the response; i should have posted the code that gave rise to the error - apologies.

I think I had the right line - this is the file that resulted in the error:

{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]File "usr/bin/python3", line ([0-9])*)",
"selector": "source.python"
}

Can I ask you to let me know what I am doing wrong?

@zaemiel
Copy link
Author

zaemiel commented Feb 29, 2020

Hi
I am trying this in Linux (LXLE), and get the following error message when trying the print(sys.version) command:
/usr/bin/python3: can't find 'main' module in ''
[Finished in 0.3s with exit code 1]
[cmd: ['python3', '-u', '']]
[dir: /opt/sublime_text]
[path:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
I would be really grateful if anyone could help me correct this.
Thanks in advance.

"cmd": ["python3", "-u", "$file"],

Hi

Thanks for the response; i should have posted the code that gave rise to the error - apologies.

I think I had the right line - this is the file that resulted in the error:

{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]File "usr/bin/python3", line ([0-9])*)",
"selector": "source.python"
}

Can I ask you to let me know what I am doing wrong?

Have you saved the file before you tried to run it?

@Kulu21
Copy link

Kulu21 commented Feb 29, 2020

Hi
I am trying this in Linux (LXLE), and get the following error message when trying the print(sys.version) command:
/usr/bin/python3: can't find 'main' module in ''
[Finished in 0.3s with exit code 1]
[cmd: ['python3', '-u', '']]
[dir: /opt/sublime_text]
[path:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
I would be really grateful if anyone could help me correct this.
Thanks in advance.

"cmd": ["python3", "-u", "$file"],

Hi
Thanks for the response; i should have posted the code that gave rise to the error - apologies.
I think I had the right line - this is the file that resulted in the error:
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]File "usr/bin/python3", line ([0-9])*)",
"selector": "source.python"
}
Can I ask you to let me know what I am doing wrong?

Have you saved the file before you tried to run it?

I did, I saved it in the directory that I was prompted to save into.

@Olumidemighty
Copy link

outputerror python
please which plugin do i need to install to make the console interactive

@ramosvacca
Copy link

Working on Ubuntu 18.04, SublimeText3. Python 3.6.9

@Olumidemighty
Copy link

thanks

@Think3wang
Copy link

Thank you for this sharing, although I don't understand the Regex, I saw other blogs write the same thing so I give it a try. Now the Command + B will build my .py file with python3 command. Thank you so much.

@plasmasparc
Copy link

Thank you, it is a nice solution!

@purplesrl
Copy link

actually after I installed the Anaconda package a new option popped up, its called "Anaconda Python Builder" which works fine on my Python 3 files without any changes, of course my default python_interpreter is python3

{
"name": "Anaconda Python Builder",
"shell_cmd": ""${python_interpreter}" -u "$file"",
"file_regex": "^[ ]File "(...?)", line ([0-9]*)",
"selector": "source.python"
}

@erfun4
Copy link

erfun4 commented May 17, 2020

thanks a lot

@KamelSiddiqui
Copy link

hi, can you help me install PySigmoid Package? on Python3. pip install PySigmid is not providing any help.
thanks

@CarlitoUK
Copy link

Hey Zaemiel, this worked fine, thank you very much

@frroossst
Copy link

Thanks mate!

@chanhoiying
Copy link

Thank you @zaemiel and @Jensenkho!

I was close to giving up on learning Python!

@rafaelgramoschi
Copy link

rafaelgramoschi commented Sep 27, 2020

No Build System

On Linux: NO BUILD SYSTEM FOUND.
Because I first had this (check the ASTERISKS!):
Screenshot_2020-09-27_11-15-52
Changed to this:
Screenshot_2020-09-27_11-14-01

@spicynuggets02
Copy link

thank you so much! other versions of this code do not work on python 3.9

@Fanman001
Copy link

Am trying to use Sublime Text 3 (Build3211) with Python 3.9.0 on Windows 10.

Have downloaded both successfully and

  1. Gone to Sublime Text to: Tools -> Build System -> New Build System
    and put the next lines:

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

Then saved it with a meaningful name like: python3.sublime-build

But when I write a program like:

print("Help") and run under Sublime Text to Tools Python 3, I get the following message:

Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640[Finished in 0.3s]

Am just beginning to learn how to code... PLEASE HELP!

@Fanman001
Copy link

Am trying to use Sublime Text 3 (Build3211) with Python 3.9.0 on Windows 10.

Have downloaded both successfully and

  1. Gone to Sublime Text to: Tools -> Build System -> New Build System
    and put the next lines:

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

Then saved it with a meaningful name like: python3.sublime-build

But when I write a program like:

print("Help") and run under Sublime Text to Tools Python 3, I get the following message:

Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640[Finished in 0.3s]

Am just beginning to learn how to code... PLEASE HELP!

@zaemiel
Copy link
Author

zaemiel commented Nov 28, 2020

Am trying to use Sublime Text 3 (Build3211) with Python 3.9.0 on Windows 10.

Have downloaded both successfully and

1. Gone to Sublime Text to: Tools -> Build System -> New Build System
   and put the next lines:

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

Then saved it with a meaningful name like: python3.sublime-build

But when I write a program like:

print("Help") and run under Sublime Text to Tools Python 3, I get the following message:

Python was not found but can be installed from the Microsoft Store: [https://go.microsoft.com/fwlink?linkID=2082640Finished in 0.3s]

Am just beginning to learn how to code... PLEASE HELP!

Did you install Python?
Go to the https://www.python.org/downloads/
Download and install (when it will ask you to include the path to Python to the PATH environment variable you should agree).

Open cmd and input python...

Also Windows has no 'python3', only 'python' - the command you use to get the Python's shell.

@adilbeksultanov
Copy link

Thank you very much!

@codebyAbhishekBharti
Copy link

Thanks a lot

@benjaminjm112
Copy link

Hi, I get this message: [Errno 2] No such file or directory

Any idea how to fix this?

Try this code:
{ "shell_cmd": "gnome-terminal --working-directory=$file_path -- bash -c 'python3 -u \"$file\" && read -n 1 -s -r'", "working_dir": "$file_path", "selector": "source.python", "env": {"PYTHONIOENCODING": "utf-8"} }

@hacker101red
Copy link

i cant give input

@prisilya07
Copy link

thank you its work to me! but i change code a little bit. if you guys still have a problem like the code not build, you can try this code
{
"cmd": ["C:\Python\Python397\python.exe", "-u", "$file"],
"file_regex": "^[ ]File "(...?)", line ([0-9]*)",
"selector": "source.python"
}

i hope this will help you guys :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment