How to run python script in terminal mac4/13/2023 ![]() If you have spaces or certain other symbols somewhere in your filename you need to enclose the file name in quotes: python3 "~/Downloads/some directory with spaces/and a filename with a | character. ![]() py file in Finder.app and just drag it into the Terminal.app window which should type out the absolute path for you. Instead of typing out that whole thing ( ~/Downloads/my_script.py), you can find the. You can also skip step 3 and give python3 an absolute path instead python3 ~/Downloads/my_script.py Run the script using the python3 executable python3 my_script.py Install Python using Homebrew brew install pythonĬd into the directory that contains your Python script (as an example I'm using the Downloads ( Downloads) folder in your home ( ~) folder): cd ~/Downloads Install Homebrew (by pasting the following text into Terminal.app and pressing the Enter key) /bin/bash -c "$(curl -fsSL )" Open Terminal.app (press ⌘+Space and type "Terminal" and press the Enter key) There are many ways of installing Python, but Homebrew is the easiest. ![]() Let's say your script is called my_script.py and you have put it in your Downloads folder. Open Terminal.app (press +Space and type Terminal and press the Enter key) Install Python using Homebrew cd into the directory that contains your Python. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |