Sublime Forum

Cannot run file from sublime text (cmd+B)

#1

I recently installed sublime text and could run files without any problem. I configured sublime to use the correct python version.

A few days later I reinstalled Anaconda on my computer. Now, I cannot run the files from sublime text anymore. There is the following error:

[Errno 2] No such file or directory: ‘python3’

I am confused. In my Terminal I have python version 3.8. Is it because Anaconda has only version 3.7?

Thanks for your help, I am stuck.

[Errno 2] No such file or directory: 'python3'
[cmd: ['python3', '-u',      '/Users/andreamathis/Desktop/pythonCrashCourse/ch2/n ame.py']]
[dir: /Users/andreamathis/Desktop/pythonCrashCourse/ch2]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
0 Likes

#2

Please paste the contents of your ST console. It looks like the shell helper has issues loading your login shell configuration which sets up your environment variables like $PATH.

0 Likes

#3

Hi @FichteFoll, thanks for your reply.

The Python3.sublime-build file is:
{
“cmd”: [“python3”, “-u”, “$file”],
}

The Python3.sublime-build file is in my User/Library/Application Support/Sublime Text 3/Packages/User folder

I don’t see what is wrong. I hope you can help, thank you…

0 Likes

#4

The console is available through the View → Show Console menu item (I hope this is also the case on macOS).

0 Likes

#5

Like this?

0 Likes

#6

On my desktop computer I have created the same .sublime-build file and it is located in the same directory. But on my Macbook Air it does not work…

0 Likes

#7

Have you installed python3 on both of your systems?

0 Likes

#8

Hi @bschaaf thanks for your message. Yes, I have python 3.8 on both systems.

0 Likes

#9

Hey @bschaaf and @FichteFoll: I think now it works again…

I have no clue why it is working now…I created a symlink to my iCloud folder this morning and tried out to run python files from ST and all of a sudden it worked again :slight_smile:

I hope it will continue to work, thanks for your help!!

0 Likes

#10

Hi @DataMower, Im also reading the same book to learn python. Im instaled Python v3.8 and sublime text has the book advise.

the problem that I have is similar to yours and can´t get printed the firs exercise. The error that send me is this:

[WinError 2] El sistema no puede encontrar el archivo especificado
[cmd: [‘python3’, ‘-u’, ‘C:\Users\Ricardo\Dropbox\Mis documentos 2018\python_work\hello_world.py’]]
[dir: C:\Users\Ricardo\Dropbox\Mis documentos 2018\python_work]
[path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Users\Ricardo\AppData\Local\Programs\Python\Python38\Scripts;C:\Users\Ricardo\AppData\Local\Programs\Python\Python38;C:\Users\Ricardo\AppData\Local\Programs\Python\Launcher;C:\Users\Ricardo\AppData\Local\Microsoft\WindowsApps;]
[Finished]

Please, can you help me to solved?.

Best Regards.

0 Likes

#11

Hey @Rick77, I don‘t know how I managed to resolve the problem, but now everything works fine. Just before I wanted to re-install sublime text…

Have you correctly created the build system? It seems that you work on a windows computer…

You can also try to re-install sublime text, maybe this will work.

0 Likes

#12

Does python3 -u C:\Users\Ricardo\Dropbox\Mis documentos 2018\python_work\hello_world.py work from cmd.exe?

0 Likes

#13

There’s no python3 on Windows, the command is just python. And the default sublime build does invoke python by default.

@Rick77 remove any special configuration you made for the python build, or at least change the executable name to python without the 3.

0 Likes

#14

I have problems again to run files from sublime text. I get the same error as before:

.

Why does it not work and sometimes it does? @bschaaf @FichteFoll @An_dz can anybody help, please? I have no idea where the bug can be…


Python 3 is installed an starts up when I enter python3…

Thanks.

0 Likes

#15

image
As shown in your screenshot, I think the base indicates you are under Anaconda’s env.

I do not think ST can reads PATH from Anaconda’s env unless there is some magic things involve in.

I am not using Anaconda so I have no decent suggestion for you personally. Maybe just found out where is the python3 via $ which python3 and add the path to PATH. Another way can be making a soft-link like /usr/local/python3 (I guess /usr/local is likely already in PATH) to it but I am not sure it will work or not.

Since Anaconda is popular, there can be already solutions as well. For example, https://dev.to/abdurrahmaanj/using-anaconda-on-sublime-text-39le .

1 Like

I cant build with python 3
#16

hi @jfcherng, thanks for your post and the link related to anaconda!

0 Likes

#17

Thanks for your answer.

0 Likes

#18

Thanks for your answer.

0 Likes

#19

Thanks!!!
It works!!!
the book was wrong.

Best regards

0 Likes

#20

I think I have found the reason for the error:

The error appears at my system in the following workflow:
open sublime --> write a script --> save it under a name --> then run it directly

Everything works, when I first save AND close the file after writing it. When I reopen it (either through the finder or directly in sublime) and then run the file, then it works!

Is this a normal behaviour with sublime?? In my opinion it is strange that I have to shut down the file first and then reopen it to make it run correctly. What is your opinion?

0 Likes