Home > Article > Backend Development > How to use python on mac
How to use python on mac?
Build a python environment on mac: The mac system actually comes with a python execution environment, which is fine for running python, but it may not be enough for development, so we need to reinstall python.
Recommended: "Python Tutorial"
There are two installation solutions: 1.homebreWbrew install python, this solution is relatively simple , if something goes wrong, you can try adding sudo to the front. The installed python may not be the latest version.
Download and install from the official website. You can download and install the latest version of python from https://www.python.org/download. The installation is relatively brainless. Just press it all the way. OK, the disadvantage is that you have to maintain it yourself for future upgrades and uninstallations.
The locations of python installed by these two methods are different. You can use: which python to view the installation location. After the installation is complete, type python in the terminal. Verify that the installation was successful.
Terminal execution: cd to the folder directory, add #!/usr/bin/env python in the first line of the file, add permissions chmod 777 filename.py, and execute the script. /filename.py, simple script: files.py.
The above is the detailed content of How to use python on mac. For more information, please follow other related articles on the PHP Chinese website!