質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

1199閲覧

homebrewでpython3.9のインストールでエラーが起きる

matsuochinyu

総合スコア57

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2022/07/19 07:50

編集2022/07/19 08:33

前提

その前にも同様のエラーがおき、brew postinstall python@3.9をしろと言われたのでしたのですが、また同じエラーが起きてしまい使えなくて困っています。
PATHを通そうとしても使えず、python3.8が代わりに出てきます。
どうか解決方法を教えて下さい。

発生している問題・エラーメッセージ

==> Postinstalling python@3.9 ==> /usr/local/Cellar/python@3.9/3.9.13_1/bin/python3 -m ensurepip ==> /usr/local/Cellar/python@3.9/3.9.13_1/bin/python3 -m pip install -v --no-deps --no-index --upgrade --isolated --target=/usr/local/lib/python3.9/site-packages /usr/local/Cel Last 15 lines from /Users/matsuochinyu/Library/Logs/Homebrew/python@3.9/post_install.02.python3: File "/Users/matsuochinyu/Library/Python/3.9/lib/python/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper return func(self, options, args) File "/Users/matsuochinyu/Library/Python/3.9/lib/python/site-packages/pip/_internal/commands/install.py", line 466, in run self._handle_target_dir( File "/Users/matsuochinyu/Library/Python/3.9/lib/python/site-packages/pip/_internal/commands/install.py", line 521, in _handle_target_dir shutil.rmtree(target_item_dir) File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 734, in rmtree _rmtree_safe_fd(fd, path, onerror) File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 667, in _rmtree_safe_fd _rmtree_safe_fd(dirfd, fullname, onerror) File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 690, in _rmtree_safe_fd onerror(os.unlink, fullname, sys.exc_info()) File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py", line 688, in _rmtree_safe_fd os.unlink(entry.name, dir_fd=topfd) PermissionError: [Errno 13] Permission denied: 'configuration.py' Warning: The post-install step did not complete successfully You can try again using: brew postinstall python@3.9

zshのなか

### プラグイン管理 autoload -Uz _zinit ### Added by Zinit's installer if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit" command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \ print -P "%F{33} %F{34}Installation successful.%f%b" || \ print -P "%F{160} The clone has failed.%f%b" fi source "$HOME/.local/share/zinit/zinit.git/zinit.zsh" autoload -Uz _zinit (( ${+_comps} )) && _comps[zinit]=_zinit ## 便利プラグや設定 ## コマンドシンタックスハイライト zinit load zsh-users/zsh-syntax-highlighting ## 入力補完(コマンド履歴に基づいてコマンド候補を表示:単体) zinit load zsh-users/zsh-autosuggestions ## 入力補完(コマンドやファイル名の入力中にTabキーを推すことで入力候補を表示:複数) zinit ice wait'0'; zinit load zsh-users/zsh-completions autoload -Uz compinit && compinit ## 補完で小文字でも大文字にマッチさせる zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' ## 補完候補を一覧表示したとき、Tabや矢印で選択できるようにする zstyle ':completion:*:default' menu select=1 ## コマンド履歴を検索(Ctrl+R) function peco-history-selection() { BUFFER=`history -n 1 | tac | awk '!a[$0]++' | peco` CURSOR=$#BUFFER zle reset-prompt } zle -N peso-history-selection bindkey '^R' peco-history-selection ## コマンド履歴からディレクトリ検索・移動 if [[ -n $(echo ${^fpath}/chpwd_recent_dirs(N)) && -n $(echo ${^fpath}/cdr(N)) ]]; then autoload -Uz chpwd_recent_dirs cdr add-zsh-hook add-zsh-hook chpwd chpwd_recent_dirs zstyle ':completion:*' recent-dirs-insert both zstyle ':chpwd:*' recent-dirs-default true zstyle ':chpwd:*' recent-dirs-max 1000 zstyle ':chpwd:*' recent-dirs-file "$HOME/.cache/chpwd-recent-dirs" fi function peco-cdr () { local selected_dir="$(cdr -l | sed 's/^[0-9]* *//' | peco)" if [ -n "$selected_dir" ]; then BUFFER="cd ${selected_dir}" zle accept-line fi } zle -N peco-cdr bindkey '^E' peco-cdr ## カレントディレクトリ以下のディレクトリ検索・移動 function find_cd() { local selected_dir=$(find . -type d | peco) if [ -n "$selected_dir" ]; then BUFFER="cd ${selected_dir}" zle accept-line fi } zle -N find_cd bindkey '^X' find_cd ### Zsh(Iterm2)の設定 ## ターミナルの上(タブ)にカレントディレクトリを表示 precmd() { eval 'echo -ne "\033]0;$PWD\007"' } ## zsh-completions(補完機能)の設定 if [ -e /usr/local/share/zsh-completions ]; then fpath=(/usr/local/share/zsh-completions $fpath) fi autoload -U compinit compinit -u ### PATHを通す export LANG=ja_JP.UTF-8 export PS1="%~ %# " export PATH="/usr/local/bin:$PATH" export PATH="/usr/local/sbin:$PATH" export PATH=/bin:/usr/bin:/usr/local/bin:${PATH} export PATH=$HOME/.nodebrew/current/bin:$PATH export NODE_PATH="/Users/matsuochinyu/.nodebrew/node/v18.0.0/bin" export PATH="/usr/local/opt/mysql/bin:$PATH" export PATH="/usr/local/opt/mysql-client/bin:$PATH" export PATH="$PATH:/opt/homebrew/bin/" export PATH=$H2_HOME/bin:$PATH ### anyenv(ほぼ全てのプログラミング言語のenv) eval "$(anyenv init -)" ### mysqlの設定 export LDFLAGS="-L/usr/local/opt/mysql-client/lib" export CPPFLAGS="-I/usr/local/opt/mysql-client/include" export PKG_CONFIG_PATH="/usr/local/opt/mysql-client/lib/pkgconfig" ### Pythonの設定 ## Python3 ## python3.10 #export PATH="/usr/local/opt/python@3.10/bin:$PATH" #export LDFLAGS="-L/usr/local/opt/python@3.10/lib" #export PKG_CONFIG_PATH="/usr/local/opt/python@3.10/lib/pkgconfig" ## python3.9 #export PATH="/usr/local/opt/python@3.9/libexec/bin:$PATH" alias python='python3' alias pip='python -m pip' alias pipf='pip freeze' ## Python2 export PATH="$HOME/Library/Python/2.7/bin:$PATH" alias python2='python2' alias pip2='pip2' ### Goの設定 export GO111MODULE=auto export GOROOT="/usr/local/Cellar/go/1.18.4/libexec" export GOPATH="$(go env GOPATH)" export PATH=$PATH:$(go env GOPATH)/bin ### cの設定 ## 〇〇.outだけでできるようになる export PATH=.:$PATH ### Rubyの設定 export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init - zsh)" ### Javaの設定 export CPPFLAGS="-I/usr/local/opt/openjdk/include" export M2_HOME=/usr/local/Cellar/maven/3.8.1/libexec/ export JAVA_HOME='/usr/libexec/java_home -v 18' export PATH=${JAVA_HOME}/bin:${PATH} ### PHPの設定 export PATH="/usr/local/opt/php/bin:$PATH" ### Aliasの設定 ## プログラミング alias ts='tsc' ## その他 alias c='clear' alias h='history' alias ls='ls -a' alias tree='tree -a' alias rm='rm -r' alias cp='cp -r' alias vzsh='vim ~/.zshrc' alias ozsh='open ~/.zshrc' alias szsh='source ~/.zshrc' alias maven='mvn' ### setupの設定 ## 日本語のファイル名も表示可能にする setopt print_eight_bit ## cdなしでもディレクトリを入力するだけで移動可能 setopt auto_cd ## 同時に起動しているzshの間でhistoryを共有する setopt share_history ## 同じコマンドをhistoryに残さない setopt hist_ignore_all_dups ## 環境変数を保管 setopt AUTO_PARAM_KEYS ### その他 #ssh-add -K ~/.ssh/id_rsa ## コマンドプロンプト(Powerlevel10k)の設定 # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi source ~/powerlevel10k/powerlevel10k.zsh-theme # To customize prompt, run p10k configure or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zshexport

補足情報(FW/ツールのバージョンなど)

MacOS:catalina 10.15.7

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hoshi-takanori

2022/07/19 08:03

Permission denied と言ってるので、homebrew を構成するファイルのパーミッションがおかしくなってるのかも。(もしかして sudo で何かしたとか?) とりあえず brew doctor したら何が出ますか?
matsuochinyu

2022/07/19 08:09

``` Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks! Warning: /usr/bin occurs before /usr/local/bin in your PATH. This means that system-provided programs will be used instead of those provided by Homebrew. Consider setting your PATH so that /usr/local/bin occurs before /usr/bin. Here is a one-liner: echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc The following tools exist at both paths: phpize idle python3 phar.phar pydoc pip3 phar php python-config tidy php-config ``` という風に出ます。`export PATH="/usr/local/bin:$PATH"`に関してはちゃんと書いてるのですが、なぜかこう出てきます。
hoshi-takanori

2022/07/19 08:16

PATH は : で区切られてて、前にあるものが優先されますので、/usr/local/bin より /usr/bin が前にあるため、macOS がもともと持ってる Python などが Homebrew で入れたものよりも優先されてしまう、と言ってますね。 なぜそうなるかは、.zshrc 全体をチェックする必要がありそうです。
matsuochinyu

2022/07/19 08:34

編集をしてzshの中身全部のせました。 できれば確認しただけると幸いです。
matsuochinyu

2022/07/19 08:35

あと、一応ですけど、/etc/pathsのなかは以下の通りになってます。 /usr/local/bin /usr/bin /bin /usr/sbin /sbin
hoshi-takanori

2022/07/19 08:46

export PATH=/bin:/usr/bin:/usr/local/bin:${PATH} のせいですね。(/etc/paths はたぶん PATH の初期値なので、.zshrc に変なこと書いたら意味ないです。)
matsuochinyu

2022/07/19 09:00

そちらの部分を削除しました、そうしたらpython3.9になりました。本当にありがとうございます。。。 解決した矢先に申し訳ないのですが、`python postinstall python@3.9`としたら質問内容と同じエラーが出てきたのですが、こちらは無視という形でいいのでしょうか?
hoshi-takanori

2022/07/19 09:38

何かのパーミッションがおかしくなってるように見えますが、どれかはよく分からないですね。 もう一度 brew doctor したら何か出ますか?
matsuochinyu

2022/07/19 14:24

`Your system is ready to brew.`と出てきます。
guest

回答1

0

自己解決

zshの問題でした。
回答してくださったhoshi-takanoriさん、ありがとうございます。

投稿2022/07/20 15:34

matsuochinyu

総合スコア57

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問