I tried Python on Mac for the first time.

Introduction

Nice to meet you. My name is Taro and I'm Qiita's first post. I've been a member of society for about 4 years, and as a developer I've been writing code for about two and a half years. Others are the type of person who defines requirements, is close to PM, consults for recruitment, and is fluttering.

At home, I rarely write Python using a desktop PC, I was developing business tools that I didn't want to do with gas, Somehow I wanted to get my hands on a Mac and bought a Macbook at the end of last year. I immediately decided to write a simple crawl tool in Python, but It took some time to build the environment unlike Windows, so This time (~~ miscellaneous ~~) I will leave what I did at that time as a memo. ~~ * If you just write the code locally, it seems that Python2 is included by default ~~

skill

environment

・ MacBook Pro (13-inch 2016) -MacOS Catalina Version 10.15.2 ・ Xcode Version 11.3

Goals and things to do

  1. Install Xcode
  2. Install Homebrew
  3. Install pyenv
  4. Install Python 3. ○. ○ (what you want to install)
  5. Display of "Hello world!"

Install Xcode

Install as appropriate from the App store.

Homebrew installation

Copy and paste the installation command from Homebrew Official HP and execute it. [Example] /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

When you execute it, you will be asked for return and Password, so enter them as appropriate.

If the installation is successful, the following log will be displayed.

(Omission)
Tapped 2 commands and 4889 formulae (5,148 files, 12.8MB).
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh

At this time, if the following log is displayed and the installation fails, Go to Apple's Developer Page, download the required version of "Comand line tools for xcode", and then use the Homebrew command again. You can avoid this by executing.

(Omission)
xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'
Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

After successful installation, execute the following command to update Homebrew and check the version. brew update brew -v The following log will be displayed.

user@host $ brew update
Already up-to-date.
user@host $ brew -v
Homebrew 2.2.4
Homebrew/homebrew-core (git revision 5889; last commit 2020-01-24)

Install pyenv

pyenv is software that installs and version controls Python. Install pyenv using Homebrew that you installed earlier. brew install pyenv If the installation is successful, you can check the version with the following command. pyenv -v

user@host $ pyenv -v
pyenv 1.2.16

Install Python3. ○. ○ (what you want to put in)

Install Python using pyenv. This time I will also install the latest one. pyenv install 3.8.1

After installation, change the version of Python you want to use to the one you have installed. pyenv global 3.8.1 After making changes, check if the settings are reflected. pyenv versions If it is reflected, I think that "*" is displayed next to the version of Python to be used.

user@host $ pyenv versions
  system
* 3.8.1 (set by /Users/***/.pyenv/version)

Display of "Hello world!"

After that, please enter the following command to display it.

python3 print("Hello world!")

user@host $ python3
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello world!")
Hello world!

This is the start of Python life on Mac. Thank you for your hard work!

Recommended Posts

I tried Python on Mac for the first time.
I tried python on heroku for the first time
I tried python programming for the first time.
I tried tensorflow for the first time
I tried using scrapy for the first time
I tried Mind Meld for the first time
What I got into Python for the first time
See python for the first time
AI Gaming I tried it for the first time
I tried running PIFuHD on Windows for the time being
I tried the Google Cloud Vision API for the first time
MongoDB for the first time in Python
[Python] I tried substituting the function name for the function name
vprof --I tried using the profiler for Python
Kaggle for the first time (kaggle ①)
I tried logistic regression analysis for the first time using Titanic data
Kaguru for the first time
Since I'm free, the front-end engineer tried Python (v3.7.5) for the first time.
For the first time, I learned about Unix (Linux).
Looking back on the machine learning competition that I worked on for the first time
[For self-learning] Go2 for the first time
Start Django for the first time
I want to move selenium for the time being [for mac]
Miscellaneous notes that I tried using python for the matter
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
I installed the retro game engine pyxel for Python on Mac and started the sample code
First time python
Differences C # engineers felt when learning python for the first time
I tried using the python module Kwant for quantum transport calculation
Python Master RTA for the time being
First time python
I tried to display the video playback time (OpenCV: Python version)
python on mac
Python: I tried the traveling salesman problem
Let's try Linux for the first time
I tried the Python Tornado Testing Framework
I tried to create serverless batch processing for the first time with DynamoDB and Step Functions
The story of releasing a Python text check tool on GitHub x CircleCI for the first time
What I learned by writing a Python Pull Request for the first time in my life
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
I tried to refer to the fun rock-paper-scissors poi for beginners with Python
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
I tried putting various versions of Python + OpenCV + FFmpeg environment on Mac
For the first time in Numpy, I will update it from time to time
A useful note when using Python for the first time in a while
I tried "smoothing" the image with Python + OpenCV
How to use MkDocs for the first time
I tried "differentiating" the image with Python + OpenCV
I tried simulating the "birthday paradox" in Python
I tried the least squares method in Python
Use logger with Python for the time being
Run yolov4 "for the time being" on windows
[Note] Deploying Azure Functions for the first time
Before the coronavirus, I first tried SARS analysis
I played with Floydhub for the time being
[Python] I searched for the longest Pokemon Shiritori
I tried "binarizing" the image with Python + OpenCV
I tried using the Datetime module by Python
At the time of python update on ubuntu
I tried playing with the calculator on tkinter
Try posting to Qiita for the first time