The author's first single book "Python programming that can be enjoyed with Minecraft" (http://amzn.asia/fgFwQia) It seems that some readers are confused about building an environment in Amazon's review, so let's think about building an environment for Python 3 on Mac.
Since the above-mentioned book uses the officially distributed binary, this time I will try to build the environment with the official binary. (There are various methods, and this method is not always correct. If you find any mistakes, please let us know in the comments.)
First, select "Download" on the official website (https://python.org). Then, the screen will look like image 1, so download Python 3.6.2. * Note 1: The download method differs depending on the browser. I downloaded it using Chrome </ b>
Image 1 Python downloadWhen the download is complete, it will be in the finder's "Download" folder python-3.6.2-macosx10.6.pkg The file is saved. Note 2: The save location may have been changed depending on the browser settings (in the case of Chrome, there is an item called "Download" in the detailed settings of the environment settings). </ b>
If you can see this file in the folder (download in my case), Step 1 is complete.
python-3.6.2-macosx10.6.pkg Double-click the file Then a screen like image 2 will be displayed.
Note 3 If you are not the administrator of the Mac you are trying to install, you may need an administrator password </ b>
Image 2This completes Step 2.
Start using the terminal software (hereinafter referred to as "terminal"). You can launch the terminal software in Finder's Go-> Utilities-> Terminal.
When you start it, a screen like image 3 will be displayed.
Image 3When this screen is displayed
python3
Enter.
Note 4: If python3 does not start even if you enter the command python3, check that the entered characters are correct (the command is a secret word. If you do not say it correctly, it will not work) </ b>
If it works properly, it will start up like image 4.
Image 4When quitting Python, enter ```exit () `` `. (As in image 5)
Image 5This completes Step 3.
Note 1: What is a terminal? </ i> A terminal is software that allows you to operate the OS (Mac in this case) with commands (specific text strings).
First, try typing `python`
in the terminal. Curiously Python works.
Let's take a closer look at the working Python screen. As shown in image 5, the characters Python 2.7.10 ~ should be displayed. The version to start is different.
Note 5: A version called Python 2 series is installed on Mac as standard (actually, development of 2 series is scheduled to end. If you want to study new, please come to 3 series) </ b>
Well, it's a little difficult from here.
Enter `vi ~ / .bashrc`
in the terminal as shown in image 7. Half-width space between vi and ~.
Note 6: Check if ~ / .bashrc after vi is entered in this way. Isn't it ~ / bashrc or /.bashrc? </ b>
Image 7When the vi editor starts up, enter the following characters. For how to use Vi, refer to Qiita's article etc. For example: Vim course starting from knowledge 0
~/.bashrc
alias python=python3
alias pip=pip3
After editing .bashrc, edit the file called .bash_profile. Add `` `source ~ / .bashrc``` to the last line.
~/.bash_profile
export TERM=xterm
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
source ~/.bashrc
This completes the setting. (This post will be added as appropriate.)
Recommended Posts