2

I am just trying to code print("Hello World") and the Sublime Text editor is giving me the error

[WinError 2] The system cannot find the file specified [cmd: ['python3', '-u', 'C:\Users\DELL\Desktop\python_work\hello_world.py']] [dir: C:\Users\DELL\Desktop\python_work] [path: C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Windows Live\Shared;C:\Users\DELL\AppData\Local\Programs\Python\Python38\Scripts] [Finished]

Now I have created a new build by Tools>Build System>New Build System and in that I changed

{
    //"shell_cmd": "make"
     "cmd": ["C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python38", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

and saved it as file in sublime folder but it's still showing the same error.

What is going wrong and how can I build my Python code with Sublime Text?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Krattza
  • 21
  • 1
  • 1
  • 4
  • 1
    You don't mention it specifically in your question, so just in case note that in addition to saving a new build file you also have to choose it from the list of build systems in the menu or when Sublime asks you to choose the build to use. Apart from that I would as suggested in the answer below double check that the full path to the python interpreter that you're using is correct. – OdatNurd Jan 19 '20 at 19:17

4 Answers4

1

Make sure to check that the file is located exactly where the program thinks it is and that the filename is the same.

"[WinError 2] The system cannot find the file specified" might help.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Noah.Ehrnstrom
  • 172
  • 1
  • 12
  • See "[Don’t use “click here” and other common hyperlink mistakes](https://medium.com/@heyoka/dont-use-click-here-f32f445d1021)". – the Tin Man Jan 23 '20 at 04:28
1

I would recommend this:

  1. Open cmd and run python using py or python or python3. Search which works. Copy this. I'll call X 2.Changing in the line to "cmd": ["X", "-u", "$file"]
  2. Save as a new build system
  3. Build your code with the build system
9395
  • 51
  • 1
0

The problem is that Sublime by default tries to run Python scripts with the "py" command in a console. However that only works if a Python launcher is installed, but that doesn't have to be the case on Windows. It's the same problem as in How to edit Sublime Text build settings? and either requires you to add a custom build setting or edit the Sublime build settings for Python and replace "py" with "python" for example.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
-2

WinError 2] The system cannot find the file specified [cmd: ['H:/python/py3.7.9/python.exe', '-u', 'C:\Users\Ashwin Kumar\AppData\Roaming\Sublime Text 3\Packages/Kivy Language/preview/kv.preview.py', 'H:\python\development\kivy_venv\Lib\site-packages\ftapp.py', 'H:\python\development\kivy_venv\first_app']] [dir: H:\python\development\kivy_venv\Lib\site-packages] [path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;F:\oracle\product\10.2.0\db_1\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Lenovo\FusionEngine;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\DTS\Binn;C:\Program Files\Windows Fabric\bin\Fabric\Fabric.Code;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\dotnet;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\py3.7.9;C:\py3.7.9\Scripts;C:\py3.7.9\Lib\site-packages;C:\py3.7.9\Lib\site-packages\kivy;C:\python_3.8\Scripts;C:\python_3.8;C:\Users\Ashwin Kumar\AppData\Local\Microsoft\WindowsApps;C:\Users\Ashwin Kumar\AppData\Local\atom\bin;H:\2020\py_learning\PyCharm Community Edition 2019.3.1\bin;;C:\Users\Ashwin Kumar\AppData\Local\Microsoft\WindowsApps;] [Finished]

if you get above kind of problem,just check using below steps.

for dependency package installation use below link.

https://kivy.org/doc/stable/installation/installation-windows.html#alternate-win

  1. Ctrl+Shift+p ---> to go package control windows ---->type install package , then next coming entry type package name. i.e kivy
  2. Type kivy in the text entry
  3. if package installed do step 1. istead of install package type view files, hit entre, type kivy
  4. edit the file of the path C:\Users\user-name\AppData\Roaming\Sublime Text 3\Packages\Kivy Language\Kivy.sublime-build as below.

{ "cmd": ["python.exe", "-u", "$packages/Kivy Language/preview/kv.preview.py", "$file", "$folder"], "file_regex": "^[ ]File "(...?)", line ([0-9]*)", "selector": "source.kv", }

  1. select Build System as kivy , ie... Tools-->Build System-->kivy

6.run the code (ctrl+B)

Edits are welcome!.