0

I'm new to linux and I've just started using Ubuntu 20.04 LTS to get a feel for it.

I installed the snap version of Sublime Text 3 from the software centre included and set it up like I would usually do on Windows (Install package installer, download a theme and then download SublimeREPL).

However, when I try to run it I always get the error

FileNotFoundError(2, "No such file or directory: 'python'")".

I looked to see if Python was installed and which one. I had Python 3.8.2 installed so I then proceeded to update it 3.8.4.

I then tried again to see if it worked but it still doesn't work.

How can I fix this?

Thanks,

Mr Purple

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
  • What happens if you type ```python``` into your terminal. Does it show the Python prompt? If it doesn't try type ```python3``` into your terminal and see if it shows the prompt. – Raymond C. Jul 17 '20 at 05:24
  • It starts the Python 3.8.4 shell when I type in "python3". – Carbonated Purple Jul 17 '20 at 14:46
  • Then you probably need to change your sublime repl config to python3 instead of python. If it doesn’t work you will need to link the full path to python3. – Raymond C. Jul 17 '20 at 15:02
  • Hi, sorry for the late reply, I've been trying to figure out how to do that but I can't. Could you please guide me through it? I've tried looking for where the python install is and how to add it to my SublimeREPL.sublime-settings file but I can't figure it out. So far I've tried adding the line "default_extend_env": {"PATH" : "/usr/bin/python3"}, to the file but now I get the error "NotADirectoryError(20, 'NotADirectory')". Am I using the wrong path or have I just inputted it wrong? – Carbonated Purple Jul 18 '20 at 15:19
  • In sublime text, go to build systems. Can you see python? Select it and try to run a simple print("helloworld") and see does it run? – Raymond C. Jul 20 '20 at 06:48
  • Hi, sorry for the lack of updates. I did try to run the code using python and python 3. Using python3 gave me an output but python didn't. Although python3 did work it doesn't run interactively (allowing me to input) so that's why I was looking to use SublimeREPL. However, I have now moved to the Solus distribution and am using Atom instead and it works fine. Thanks for all the help though! – Carbonated Purple Jul 21 '20 at 21:32

2 Answers2

3

I recently also faced this problem. For any future users who also run into this, here's what I did:

open: home/username/.config/sublime-text-3/Packages/SublimeREPL/config/Python

From here open Main.sublime-menu. Edit the entries so that it is the same as this: https://gist.github.com/Hckmar9/e1cb87b67a9836db4d26#file-main-sublime-menu

All you need to do really is change python to python3 a few times in the file. Once you're done, save and close. Now try again on sublime and it should work fine.

Aevin.J
  • 41
  • 6
1

With installing python3, the command that can be used for running python scripts is $python3 <script_path>.

If you look at sublimeREPL config file for python, you will see that it uses "python" command instead of "python3" and because of this, you have gotten that error. To solve this problem, you can use update-alternative command in linux to link "python" string to "python3". To do that, you can copy and paste the following command in your shell:

sudo update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20