Setting up a python variable environment for a completely new mac os installation
Before we start setting up, we need to understand how to invoke cmd on mac os. Click on the magnifying glass in the menu bar in the top right corner of Apple 🔍 or hold down command+spacebar at the same time to bring up the spotlight function.
Then search for Terminal in the search box, which is an important runtime program for our call command.
2. Installing the python interpreter：
Click on python’s official website and install the python interpreter for your computer version. Version 3.10 or above is generally recommended.
Figure1: click the download page on python official website
After you have completed the installation of python you will get the following file information. Python Launcher is the essential runner for running .py format files on your computer. IDLE, on the other hand, is similar to a piece of software that can be written to run python. However, we are used to replacing it with the more specialised programming software Pycharm.
3. Configuring the operating environment：
Once everything is ready, please open the terminal. The interface of the terminal is shown below.
Once everything is ready, please open the terminal. The terminal screen is shown below. Type the code after % and enter to make the system run the code you have written.
· Try entering this line of code and see what happens:
If the system prompts success, then python2 is already installed on the system. If the system says: command not found: python, then try the following line of code.
If it runs successfully it will say: Python 3.11.3 (v3.11.3:f3909b8bc8, Apr 4 2023, 20:12:10) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
Python has been successfully installed.
Notice the >>> symbol on the left in the picture below? The surface is now compiling the code you type in python, not cmd on a mac, which is two different language environments.
Python’s pathfinding command（Please run in mac language environment, not python language environment）
To get back to the mac’s cmd language environment, type the following line of code in the python language environment.
4. Installing packages or third party libraries using the pip command：
Before installing, we should clarify the difference between pip and pip3, otherwise, we will encounter some unsolvable problems during the installation process.
Here we first close the terminal and then re-open it.（The purpose of the operation here is to get pip to run under the system cmd command, as using the pip command in the python language environment will produce an error.）
Then we enter one side of the code in the command box.
If you get the following feedback, then the python 2.0 equivalent of pip2 is not deployed in that environment (pip is short for pip2) but that’s okay, because we are currently using python 3.0, so we will now enter the following code in the code box.
If you get the following feedback, it means that pip3 has been successfully deployed on your computer.
And pip is used in the following way:
pip3 <command> [options]
Now let’s install the first library with pip3. Please enter the following code to install it.
pip3 install requests
This enables the installation of our first third party library.
If you need to update pip3 or install pip2.0 please use the following code.
pip3 install --upgrade pip
The main third party libraries commonly used for pip are
You can install it as required, that’s about it for python on mac os, thanks for reading