This article walks you through the steps of a beginner developing a coupon distribution service for the iPhone with a RESTful API and swift. It is a very detour implementation because it was implemented while examining the technical elements one by one.
Python is already installed on the Mac, but even as of OS 10.15, it is an older version. When it comes to actually writing Python, everyone seems to have been updated to 3 series. So I also updated to 3 series, so I will record the procedure at that time.
https://prog-8.com/docs/python-env
Mac OS 10.15 Catalina Fixed network line
The recommended procedure for Mac environment is as follows.
First, check the Python version of your Mac just in case. Open a terminal and enter the following command to display the version.
$ Python -V
The version installed on my Mac was 2.7.16, a series of 2.
_ We recommend that you update Xcode to the latest version in advance. In my case, when I tried to install Homebrew with Xcode 10.3 (the latest version is 11.1 at the time of work), the update of "Command tools for Xcode 11" running during installation did not complete successfully, and I updated Xcode to the latest version. It disappeared when I updated to. _
Homebrew is a tool that installs and manages packages such as middleware required for development. Only compatible with Mac. Now, install Homebrew.
Go to Homebrew Site and copy the installation script displayed on the top page.
Paste the copied script into the terminal and run it. You may be prompted to enter the Enter key or Mac password along the way. In addition, updates such as "Command tools for Xcode 11" may be executed. If the Homebrew installation is successful, you will see something like this in your terminal.
Make sure Homebrew is installed in your terminal. Execute the command to display the version, and if the version is displayed, the installation is successful.
$ brew -v
pyenv is a tool for installing Python. First, install pyenv using Homebrew.
$ brew install pyenv
The installation was completed in a minute or two. Make sure it is installed. Execute the command to confirm the version, and if it is displayed, the installation is successful.
$ pyenv -v
To install python with pyenv, you need to add settings to a file called ".bash_profile" on your Mac. Use the command to add the code for configuration. Execute three commands. If you can set it well with the command, nothing will be displayed.
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
First, check the version of python that can be installed. Execute the following command to display the list of versions.
$ pyenv install --list
This time I decided to install 3.7.5rc1. The reason for choosing 3.7 series is that it is a major version of Python 3 series with some minor updates. 3.7 series The latest 3.7.5 rc1 was selected. The 3.8 series still has only 3.8.0 and 3.8-dev, so I'll take a look.
Install Python 3.7.5rc1 with the following command.
$ pyenv install 3.7.5rc1
Check with the command whether it was installed.
$ pyenv versions
Then, the installed Python version is displayed, but the one with "system (~") is marked with "*". In this state, the installed Python is not enabled. Enable it. Requires a global setting. If not set, an older version will be used in the system. The command is as follows.
$ pyenv global 3.7.5rc1
Run the pyenv versions command again to verify that the settings have been reflected. If the globally set Python version is enabled, the globally set Python version will be displayed when you execute the command to check the Python version.
$ python -V
This completes the Python update.
Next, let's write a simple Python program and run it
Recommended Posts