Home > Article > Backend Development > How to write and run Python using Xcode?
How to write and run Python using Xcode?
The steps to write and run Python using Xcode are:
1. Find the Python location:
Terminal input: which python
Get the installation location of python, usually /usr/bin/python. Obtaining this path is convenient for using it to build a python compilation environment.
2. Create a python program in Xcode
Open Xcode, create a new project (Shift Command N), select Cross-platform->Ohter-> ;External Build System, continue to the next step
Paste the python path you just found in the Build Tool, eg:/usr/bin/python, click Next:
3. Set Edit Scheme
After creating the project, click on the project chart in the upper left corner and select Edit Scheme
In the first option Executable in Info, select the path of python, eg:/usr/bin/python
In the second option Arguments, in the In an Arguments passed on launch, create a new .py file you are about to create, eg: main.py
In the third option Option, check Working Directory and Select the folder where the Xcode Project is located, which is the folder where your .py file is stored, and finally select OK.
4.Build and Run
Create a new file in the project (Command N), select macOS->Other->Empty, and name it just Add the file name in Scheme, eg: mian.py
Now write the code and click Run to compile and run the python program under Xcode.
The above is the detailed content of How to write and run Python using Xcode?. For more information, please follow other related articles on the PHP Chinese website!