1

I wanted to learn Python, I installed some software. I created a little execution files and none of them will execute. So I've checked my terminal and type basic things like Is, cd etc. None of them work

:Users me$ cd
:~ me$ cd
:~ me$ cd /
:/ me$ Is
-bash: Is: command not found
:/ me$ cd ~
:~ me$ cd desktop
:desktop me$ 

If I type echo $PATH, here the result:

/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I read many things about how to fix it but I don't understand. For example:

  • I don't know how to find the User Folder
  • I don't know how to get to the bash.profile

Bear in mind that I am very new to this.

  • What do you mean by "finding user folder"? pwd for current directory, cd ~/ for going to user directory by terminal. And cmd + up arrow, for going there in Finder. – ankii Aug 9 at 10:34
5

If you want to list all files/folders in a directory, you should type ls not Is. It is L, not i.

To learn python, you won't need to reach ~/.bash_profile unless you need to change versions. Just use which python or python --version and use the syntax for the version that appears. Or use online compilers for quick testing.

Suppose you have your file learn.py at Desktop, you type cd ~/Desktop, type ls to confirm, and then to run the file as a script, type python learn.py. To enter python console, type python and use it.

Wherever your file is, you could type cd in Terminal, then drag your file into Terminal window and press Enter. Terminal will resolve the path for you.

For further help, refer to Stack Overflow. :)

If you want to see bash profile, open Finder, type command + shift + . to reveal hidden files and then command + shift + G and type ~/.bash_profile in "Go To". But don't edit it unless required.

  • 1
    If location of file is not desktop, u can type cd and then drag folder into terminal window and type ENTER. That will bring you there. – Marco M. von Hagen Aug 9 at 20:49
  • 2
    @MarcoM.vonHagen Might need to point out that you shouldn't actually type ENTER, but rather press the 'Enter' key. – Glen Yates Aug 9 at 22:10
  • 1
    @GlenYates You are absolut right. <kbd>Enter</kbd> will result in Enter-key . But not in comments ;-( – Marco M. von Hagen Aug 13 at 14:11
  • @ankiiiiiii added info into answer. – Marco M. von Hagen Aug 13 at 14:23
2

if python is installed already just go to terminal, go to correct directory and type "python filename.py"

  • 4
    Welcome to Ask Different! Please note the author of the question is "very new" to Terminal; they probably don't know what you mean by "go to correct directory". – Glorfindel Aug 9 at 14:08
  • In case of 'very new' I would suggest to learn bash shell before python. That knowledge will be helpful when digging into python later on. – Marco M. von Hagen Aug 9 at 20:53
  • 1
    "if python is installed already " - When won't it be installed? – Mark Aug 13 at 20:46
  • @MarcoM.vonHagen No need for shell - you can do anything in python that shell can do - and it is a more sane syntax. Especially if you are used to GUI – Mark Aug 13 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .