【初心者必見】Mac環境でPythonをインストール

2023年10月31日Python

python
ミニマリスト_カミ

kamiです。
TwitterYoutubeもやってます。

今回はpythonのインストールについての紹介です。

Pythonをインストール

ドキュメントからインストール

コマンドからインストール

brew install python
% brew install python

Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/services, homebrew/core and homebrew/cask).
==> New Formulae
abi3audit           dockly              mentat              saf-cli
auditwheel          eatmemory           netlistsvg          scilla
badkeys             favirecon           node@20             scoutsuite
bandicoot           ggshield            numbat              sigstore
bashunit            ghc@9.4             nvimpager           smlfmt
blake3              git-mediate         onionprobe          snyk-cli
bob                 gitsign             opentofu            sqlsmith
bozohttpd           gossip              orogene             squiid
build2              gotpm               pan                 ssh-mitm
caracal             gptline             pciutils            sshportal
cariddi             haiti               perl-xml-parser     three-body
cf2tf               incus               pter                trafilatura
chainloop-cli       iocextract          python-argcomplete  uvicorn
changie             jprq                python-gdbm@3.12    vulsio-gost
cloudsplaining      jupyter-r           python-psutil       whisper-cpp
crunchy-cli         karmadactl          python-setuptools   wormhole-william
csprecon            ldeep               python-tk@3.12      xeol
dcp                 libdicom            python@3.12         zix
dezoomify-rs        libnghttp3          qalculate-qt
diffoci             llvm@16             rekor-cli
==> New Casks
affine                                   modrinth
batchoutput-pdf                          muyu
brickstore                               nvs
commandpost                              paulxstretch
devtunnel                                routine
dropbox-dash                             sf
dropshelf                                simplex
ecodms-client                            songkong
finbar                                   space-capsule
fossa                                    spacedrive
free-podcast-transcription               telegram-a
hp-easy-admin                            to-audio-converter
kuaitie                                  writerside
low-profile                              xsplit-vcam

You have 25 outdated formulae installed.

python@3.11 3.11.5 is already installed but outdated (so it will be upgraded).
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.11/manifests/3.11.6
######################################################################### 100.0%
==> Fetching dependencies for python@3.11: openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.1.4
######################################################################### 100.0%
==> Fetching openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:81f02481
######################################################################### 100.0%
==> Fetching python@3.11
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.11/blobs/sha256:f7f0fd
######################################################################### 100.0%
==> Upgrading python
  3.11.5 -> 3.11.6 

==> Installing dependencies for python@3.11: openssl@3
==> Installing python@3.11 dependency: openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.1.4
Already downloaded: /Users/kami/Library/Caches/Homebrew/downloads/528fccab152aa17857e73f54f268d413bf94e22188c0e4ff17a6c497d2783b88--openssl@3-3.1.4.bottle_manifest.json
==> Pouring openssl@3--3.1.4.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/openssl@3/3.1.4: 6,496 files, 28.4MB
==> Installing python@3.11
==> Pouring python@3.11--3.11.6.arm64_monterey.bottle.tar.gz
==> /opt/homebrew/Cellar/python@3.11/3.11.6/bin/python3.11 -Im ensurepip
==> /opt/homebrew/Cellar/python@3.11/3.11.6/bin/python3.11 -Im pip install -v --
==> Caveats
Python has been installed as
  /opt/homebrew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /opt/homebrew/opt/python@3.11/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /opt/homebrew/lib/python3.11/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.11

gdbm (`dbm.gnu`) is no longer included in this formula, but it is available separately:
  brew install python-gdbm@3.11
`dbm.ndbm` changed database backends in Homebrew Python 3.11.
If you need to read a database from a previous Homebrew Python created via `dbm.ndbm`,
you'll need to read your database using the older version of Homebrew Python and convert to another format.
`dbm` still defaults to `dbm.gnu` when it is installed.

For more information about Homebrew and Python, see: https://docs.brew.sh/Homebrew-and-Python
==> Summary
&#x1f37a;  /opt/homebrew/Cellar/python@3.11/3.11.6: 3,286 files, 62.5MB
==> Running `brew cleanup python@3.11`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /opt/homebrew/Cellar/python@3.11/3.11.5... (3,319 files, 63.2MB)
Removing: /Users/kami/Library/Caches/Homebrew/python@3.11--3.11.5... (15MB)
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/kami/Library/Caches/Homebrew/awscli--2.13.20... (17.4MB)
Removing: /Users/kami/Library/Caches/Homebrew/cffi--1.15.1... (165.3KB)
Removing: /Users/kami/Library/Caches/Homebrew/composer--2.6.3... (685.9KB)
Removing: /Users/kami/Library/Caches/Homebrew/curl--8.3.0... (1.4MB)
Removing: /Users/kami/Library/Caches/Homebrew/freetds--1.3.20... (2.8MB)
Removing: /Users/kami/Library/Caches/Homebrew/httpd--2.4.57_1... (7.2MB)
Removing: /Users/kami/Library/Caches/Homebrew/libnghttp2--1.56.0... (214.2KB)
Removing: /Users/kami/Library/Caches/Homebrew/libtiff--4.5.1... (1.7MB)
Removing: /Users/kami/Library/Caches/Homebrew/openexr--3.2.0... (1.9MB)
Removing: /opt/homebrew/Cellar/openssl@3/3.1.2... (6,495 files, 28.4MB)
Removing: /Users/kami/Library/Caches/Homebrew/openssl@3--3.1.2... (7.7MB)
Removing: /Users/kami/Library/Caches/Homebrew/php--8.2.10... (19.8MB)
Removing: /Users/kami/Library/Caches/Homebrew/sqlite--3.43.1... (2.1MB)
Removing: /Users/kami/Library/Logs/Homebrew/openssl@3... (64B)
Removing: /Users/kami/Library/Logs/Homebrew/ca-certificates... (64B)
Removing: /Users/kami/Library/Logs/Homebrew/python@3.11... (2 files, 2.5KB)
Pruned 0 symbolic links and 2 directories from /opt/homebrew
==> Caveats
==> python@3.11
Python has been installed as
  /opt/homebrew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /opt/homebrew/opt/python@3.11/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /opt/homebrew/lib/python3.11/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.11

gdbm (`dbm.gnu`) is no longer included in this formula, but it is available separately:
  brew install python-gdbm@3.11
`dbm.ndbm` changed database backends in Homebrew Python 3.11.
If you need to read a database from a previous Homebrew Python created via `dbm.ndbm`,
you'll need to read your database using the older version of Homebrew Python and convert to another format.
`dbm` still defaults to `dbm.gnu` when it is installed.

For more information about Homebrew and Python, see: https://docs.brew.sh/Homebrew-and-Python
kami@kami-3 Desktop % 

pathを追加

installが終わったらコマンドを通せるようにパスを通します。

echo 'export PATH="/usr/local/bin:$PATH"' >>
~/.zshrc source ~/.zshrc

パスをとしたら「.zshrc」または「.bash」を更新してください。

スポンサードサーチ

Pythonのバージョン確認

python3 --version
python3 -v

バージョンが返って来れば、インストールできています。

Python 3.9.6

Python

Posted by kami