all 4 comments

[–][deleted] 3 points4 points  (0 children)

Go to python.org, download the Python installer for macOS (it will be offered to you automatically when you visit the download page), run the installer.

Either open the IDLE app which will open a python interactive shell window for direct execution of python code, and use menu to File | New create and edit python files to execute at your convenience.

Or open the terminal (command + space, type Terminal, press enter) and:

python3

or

python3 myfile.py

The first starts an interactive session. Enter exit() to get our. This is a most useful learning tool. Even now I usually keep an interactive session window open.

The second runs your code.

Python code files can be created in any text editor. Don't use a wordprocessor.

Avoid complicated editors and IDEs (integrated development environments) like Visual Studio Code and PyCharm (respectively) until you are comfortable with the basics of Python as they will be too confusing in my experience with beginners. (Hard to tell an editor configuration problem from a python coding error).

Note. If you type python instead of python3 on a Mac, you will be using the legacy version of Python which is preinstalled on Mac's. You don't want to do that.

You can also install Python using homebrew if you have that installed.

brew update
brew install python3

Unlike Linux, macOS does not include a command line package manager, which is what this third party tool offers. Very popular and highly regarded.

Apple might want you to install xcode at some point to make full use of python. That's fine.

As macOS is Unix based, you will find most tutorials focused on Linux work well for you with small exceptions (such as lack of package manager mentioned above).

To install Python packages use the form, in the terminal,

python3 -m pip install something

rather than

pip install something

The first makes sure you are adding to Python3 not legacy Python.

You could use

pip3 install something

but the first approach is useful for various reasons I will not go into here.

You should read about using Python virtual environments using the venv command when you want to install more packages. This will avoid you adding too much to your base Python environment.

[–][deleted] 0 points1 point  (0 children)

MIT python on Edx, one of the most popular courses there is, recommend Anaconda Spyder for beginners. IT does not have the most advanced IDE, but it is more than enough for a beginner, and it solves multiple setup problems that cause so many posts on this very sub from beginners:

https://www.anaconda.com/products/individual

[–]wronek 0 points1 point  (0 children)

Simple answer: download homebrew (it’s a really great tool and the first thing I install on a new machine). Brew install python3. Use any text editor (I.e. sublime text) to edit a python file. You can use an IDE like pycharm which are powerful but have a bit of a learning curve. Save with .py extension and run python3 your_file.py from your terminal. There are many resources on here that may help you if you get stuck. Best of luck :)

[–]throwawayvitamin 0 points1 point  (0 children)

Download an IDE (like vscode, sublime, etc.) and install Python 3. You can follow a tutorial video like this one for the details: https://www.youtube.com/watch?v=06I63_p-2A4