Download Python Command Line Mac Os X Updated
Download Python Command Line Mac Os X
Tutorial: Installing Python on Mac
Published: Jan 12, 2022
Python is one of the most powerful programming languages, mostly used in information science, motorcar learning, and large data analytics. So, installing Python is essential for all programmers. As a novice programmer, you may be wondering how to install or update Python on your Mac properly. Here, we volition walk through the different ways of installing and updating Python on macOS.
Then, to write and run our Python code in an integrated development environs (IDE), we will learn how to install and configure Visual Studio Code on Mac. There are different methods for installing and updating Python on Mac, but allow's stick to the third principle of the Zen of Python that says: "Simple is better than complex." Accordingly, we will endeavor simple methods rather than complex ones. Before we jump into learning how to install or update Python on Mac, let's review what we're going to discuss in this tutorial:
- Installing and updating Python on Mac
- Installing Visual Studio Code on Mac
- Running our first Python script on Mac
Installing and Updating Python on Mac
I have ii pieces of news for you lot; one is good, the other bad. The good news is that for the sake of compatibility with legacy systems, Python ii.seven is pre-installed on your Mac, only the bad news is that Python 2.vii has been retired. Therefore, information technology isn't recommended for new developments. So, if you lot want to take reward of the new Python version with its many features and improvements, you need to install the latest Python alongside the version that comes pre-installed on macOS. Before we start installing the latest version of Python, permit's see why there are different versions of the same programming linguistic communication. All programming languages evolve by adding new features over time. The programming language developers announce these changes and improvements by increasing the version number.
Install Python 3 as a office of the Control Line Developer Tools
To bank check the current version of Python that is already installed, open the Terminal application by typing control + space and so spelling out terminal and hitting render. Now, type the following command, so hit return to encounter that y'all have Python two.seven pre-installed on your Mac:
% python --version
Python 2.7.18
Now, endeavour the following command to check whether or not Python 3 is installed on your Mac:
~ % python3 --version
The following message volition probably appear on the Concluding window,
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Cull an option in the dialog to download the command line developer tools.
And alongside the Terminal window, a dialog box will automatically appear that says this control requires the command line programmer tools. Offset, let's place the command-line programmer tools. To put information technology briefly, the command line developer tools bundle is a set of tools mostly used in the development process. They assistance run specific commands, such as make, git, python3, etc. So, although there are other means to install Python three.x on Mac without installing the control line developer tools, I recommend you install it because it provides a string of tools for development on Mac. To install the package, click on the Install push, and follow the steps to consummate the installation process. In one case the installation process is complete, rerun the previous control. Yes, Python 3.x is installed on your Mac.
~ % python3 --version
Python 3.viii.9
Install Python 3 with the Official Installer
Downloading the latest Python version from the official Python website (python.org) is the nearly common (and recommended) method for installing Python on a Mac. Let's endeavour it out.
i. Get-go, download an installer package from the Python website. To do that, visit https://www.python.org/downloads/ on your Mac; information technology detects your operating system automatically and shows a big button for downloading the latest version of Python installer on your Mac. If it doesn't, click the macOS link and choose the latest Python release.
two. Once the download is complete, double-click the packet to start installing Python. The installer will walk you through a wizard to complete the installation, and in well-nigh cases, the default settings piece of work well, so install it like the other applications on macOS. You may too take to enter your Mac countersign to let it know that you concur with installing Python.
Annotation If you're using Apple M1 Mac, you demand to install Rosetta. Rosetta enables Intel-based features to run on Apple silicon Macs.
3. When the installation completes, it will open up the Python folder.
iv. Let's verify that the latest version of Python and IDLE installed correctly. To exercise that, double-click IDLE, which is the integrated evolution environment shipped with Python. If everything works correctly, IDLE shows the Python shell as follows:
5. Let's write a simple Python code and run it in IDLE. Type the following statement, and hit the return key.
print("Hello, Earth!")
Or let'due south exercise a bones calculation in Python as follows:
NOTE The heady reward of this installation method is that you tin hands update an outdated Python install by downloading the latest Python installer. The new version of Python is available on your Mac once the installation is complete.
Installing Visual Studio Code on Mac
Although we tin utilize IDLE or the terminal application for writing Python scripts, we prefer to utilize a powerful, extensible, and lightweight lawmaking editor rather than rigid coding environments. In this part of the tutorial, we're going to install Visual Studio Code for Python development on macOS.
1. Starting time, you demand to download Visual Studio Code for macOS from its official website at https://code.visualstudio.com/.
2. Double-click the downloaded file to extract the archived contents.
iii. Move the Visual Studio Code application to the Application folder to brand information technology available in the macOS launchpad.
4. Launch Visual Studio Lawmaking, and then open up a binder where your Python scripts exist (or create a new one). For example, create a new folder on your Desktop, and name it py_scripts, and so try to open the folder on VS Code. Usually, VS Code needs your permission to access files in your Desktop folder; click OK.
Also, you may need to declare that you trust the authors of the files stored in your Desktop binder.
5. Create a new file with a .py extension. For example, create a new file, and name it prog_01.py. VS Code detects the .py extension and wants to install a Python extension.
To work with Python inside VS Code, we need to use the Python extension, which includes many useful features, such as code completion with IntelliSense, debugging, unit testing support, etc.
Install it by clicking on the Install push.
We tin can also install the Python extension by browsing extensions. Click on the Extensions icon on the left side of VS Code.
This will prove you a listing of the most popular VS Code extensions on the VS Code Marketplace. At present, we tin can select the Python extension and install information technology.
6. Once the extension is installed, yous have to select a Python interpreter. Click on the Select Python Interpreter push button:
Then select the recommended Python interpreter on the listing.
If you lot have multiple Python versions installed on your Mac, it'south better to choose the latest version.
Y'all also can select a Python interpreter using the Python: Select Interpreter command from the Control Palette. To do so, press CMD + SHIFT + P, type Python, and choose Select Interpreter.
Running Our First Python Script on Mac
Excellent, nosotros have everything we need to write and run our Python code inside VS Lawmaking. Let's write the following code in VS Code and so run it.
impress("Hello, World!) name = input("What'southward your proper noun? ") print("How-do-you-do {}!\nWelcome to Dataquest!".format(name)) Run the code by clicking the ▶️ push button at the summit right corner of VS Code. Starting time, it shows Hello, World! in the integrated terminal, then it asks your name; enter your proper name, and hit return. Information technology outputs Hullo <your proper noun,>, and writes Welcome to Dataquest!on the next line.
Conclusion
In this tutorial, we learned how to install the latest version of Python on Mac, as well as updating an outdated Python version. Additionally, we learned how to install Visual Studio Code as a code editor and configure it for running Python scripts. Finally, nosotros wrote a small Python script in VS Code and ran it successfully. In the next tutorial, we volition acquire about Python virtual environments and how to create and use them. Congratulations! From at present on, the heaven's the limit, and you can become a great Pythonista!
Tags
Download Python Command Line Mac Os X
Posted by: earlsely1975.blogspot.com
Post a Comment for "Download Python Command Line Mac Os X Updated"