sublime text VS os terminal - bash

I am an absolute beginner using (actually trying to) Mac High Sierra with Sublime3 and Python2.7. Just installed them.
When I test Sublime on terminal, here's what I get:
pc37:desktop flop$ one
-bash: one: command not found
I setup Sublime to write in Python and saved the file "one.py" on my desktop.
Does it come from Sublime or the OS?
I read a few debugging articles on the subject but didn't understand half of it... Didn't want to make the situation worst using wrong command lines.
Could someone help please? Thank you! Flo

You need to use valid Bash command syntax for executing Python scripts in Terminal:
python one.py
...or...
./one.py
Of course this requires you cd to ~/Desktop first.

Related

Terminal -bash: command not found errors [duplicate]

This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 2 years ago.
I messed up something in my programming a few days ago that screwed up my terminal. My terminal now gives me the a bash error message with basic functions like ls, cd, or ssh. The error looks like this: -bash: ls: command not found , where the "ls" can be replaced with any shell command.
The only way I have found to make my terminal function, is by inputting: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin" into ever terminal window I open, which can get very tedious.
It also refuses to run Python or Jupyter unless I type the aforementioned command in the terminal window first.
Go files also fail to run in terminal, and gives me a similar error message: -bash: go: command not found. This can be overcome by inputting: export PATH=$PATH:/usr/local/go/bin into the terminal window first.
I'm really worried about what is going on in my computer, and need my terminal to keep functioning in order for me to finish and pass this course (introduction to computer programming). Does anyone have any ideas as to what the problem may be, and how I could go about solving it?
Any help/advice would be greatly appreciated!!!
EDIT: I'm not sure if it is relevant, but I am using a Mac, and these problems started to occur after I attempted to download pygame (I say "attempted" because I never got a working version of pygame installed, though I did download several things in the process (XQuartz and a bunch of stuff from homebrew).
Check your .profile or .bashrc: one of those files might initialize your PATH incorrectly.
Set your PATH manually, then cd ~, and edit those two files to fix your PATH.

How to install shell commands to enable the atom command at the command line?

I have been stuck for two days looking for a solution. Could anybody please tell me how to install shell commands in Atom to enable the atom command at the command line under Windows. I know that it is not installed because when I typed which atom, it returns nothing.
Reading your other thread, I understand that you want to install a package who emulates shell commands within Atom. If so, you just have to follow the installation steps for Windows on Atom's website (I think you got confused with this which command story on the other thread, which explains how to install it on Linux and macOS).
I don't really know how to execute programs with command-line in Windows, if you don't master it either, I'd recommend using the graphics mode, and simply open your README.md file with the FILE button, like in any other software.
When you have Atom properly installed, there'll be some packages created to emule a terminal with shell commands, like this one. But this is independant from executing Atom from your computer. It emulates a terminal within Atom. I hope this is a little bit clearer.

Set path to applications for vim on mac capitan

I have used vim to make small scripts in python and typesetting things in LaTeX. So it is very useful to run applications from vim by typing :!python or :!pdflatex etcetera. But after upgrading to el capitan, this seems not to work anymore, get message like /bin/bash: pdflatex: command not found. But the funny thing is that it is possible to run the applications directly from terminal. Anyone that know how to set the correct that for vim as well?
$PATH variable not properly set in gvim/MacVim when it is opened from the finder
first check :!echo $SHELL and see if SHELL is set to bash or not
then try to set your path in your ~/.bash_profile?
export PATH=<dir_contains_pdflatex>:$PATH

Cant call PDFtk from Matlab, but can from terminal

For some reason, when I try to call PDFtk from Matlab (pdftk *.pdf cat output combFile.pdf), I get a /bin/bash: pdftk: command not found error, but I can run the same command in terminal in the same directory with no problem. I have restarted my system, but that did not seem to help. I am running Mac OSX 10.9.1 and Matlab 2013b. I do not want to use the absolute path to PDFtk, because it needs to be cross-platform compatible.
EDIT: This may help. When I echo $PATH in Matlab I get /usr/bin:/bin:/usr/sbin:/sbin. When I do it in terminal, I get /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin. Then I did which pdftkand it returned /usr/local/bin/pdftk Is there anyway to add the /usr/local/bin/ path to Matlab?
I believe that the export PATH idea would probably be better for a single system (note: I have not tested it), but I needed my script to be used on several Mac and Linux machines that are out of my control. This is what I ended up using (yes, I know that this will break on Windows, but that is ok)
if(ismac)
system('/usr/local/bin/pdftk myfig[0-9][0-9].pdf cat output myfigCombined.pdf');
else
system('/usr/bin/pdftk myfig[0-9][0-9].pdf cat output myfigCombined.pdf');
end
Originally, I was using if(isunix) for the second command, but presumably because of Mac's unix architecture both commands were being executed.
EDIT: I was able to test it on Linux and it worked perfectly. I suppose this would be the syntax for Windows, but I do not have access to a Windows machine with PDFtk and Matlab installed, so no guarantees (also, I am not sure that I did the path quotation marks right...):
elseif (ispc)
system('"C:\Program Files (x86)\PDFtk Server\bin\pdftk" myfig[0-9][0-9].pdf cat output myfigCombined.pdf');
It seems that your $PATH environment variable is not exported to Matlab. Reading
http://www.mathworks.com/matlabcentral/newsreader/view_thread/255609
I'd suggest to add a
export PATH=$PATH:<Path-to-your-PDFtk-binary>
in your .bash_profile

"subl" command not found

When I try to edit a file, like ~/.gemrc, in the terminal, I get this error:
$ subl ~/.gemrc
-bash: subl: command not found
Follow the instructions here.
If that doesn't work and you are using RVM, run: ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/.rvm/bin/subl
Note that in both of these commands, it's assumed that Sublime Text 2 is installed in your Applications directory. If its installed elsewhere change your command accordingly.
Then, enter export EDITOR='subl -w' to enable editing with the subl command.
Do you have "Sublime Text 2" installed? It's a text editor and is what the subl command would launch.
Since you don't have Sublime, you could use vim, which is installed on Mac OS, and is a very powerful text editor, but it does have a learning curve.
There's also nano, which will do for simple text editing purposes Try entering man nano at the command-line for more information. Try entering nano ~/.gemrc to create the file in question.
It sounds like you're not really familiar with your computer or its operating system. Trying to learn to program without understanding it is going to put you at a disadvantage, because languages like Ruby, Python and Perl tend to be used for a lot of OS-level code plus web and communications, which is a "heap of learning".
I'd recommend spending some time learning about the basic commands of your command-line, and get familiar with either vim or download Sublime and try it. (And, if you use Sublime or vim regularly, encourage the author by purchasing a copy -- they're very good editors and we want to keep those sort of tools around.)

Resources