zsh: command not found: ping対応

zsh: command not found: ping

となってしまい、うまくいかないので対応方法

1.以下のコマンドで動くか確認->動かない場合は、対応できないかも

/sbin/ping

f:id:harucharuru:20210121091653p:plain

2..zshrcに追記

open .zshrc
source ~/.bash_profile
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:${JAVA_HOME}:${JAVA_HOME}/bin"

f:id:harucharuru:20210121091858p:plain

3.以下の命令を実行

source ~/.bash_profile

4.ターミナルをもう一度開いてコマンドを打ってみる

ping

f:id:harucharuru:20210121091832p:plain

mac matplotlib 入らない

そのままです。
結構長い時間、mac matplotlib 入らない で悩んでいました。ググってもなかなか見つからず
ちなみに私の環境は

そんな時に出会った記事の追記
qiita.com

ということで実行
でもうまくいかず。

しかし、時間をおいたらできました。なぜだろう。

zsh: command not found: condaへの対応

環境はMac Big Sur

% sw_vers
ProductName:	macOS
ProductVersion:	11.0.1
BuildVersion:	20B29
% echo "source /opt/anaconda3/etc/profile.d/conda.sh" >> ~/.zshrc

そして、一回ターミナルを閉じてもう一回開くと

% conda -V
conda 4.9.2

無事できた!
anacondaは、デフォルトで/opt/anaconda3/にインストールされるようです。

pyenv install でエラーが出た時の対処法

Pythonの開発環境を用意しよう!(Mac) | プログラミングの入門なら基礎から学べるProgate[プロゲート]

これを見ながら進めていましたが、エラーが出てしましました。

% pyenv install 3.6.5

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.5.tar.xz...
-> https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Installing Python-3.6.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.0.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/fz/v6d_5ykj1x1b8w9c9l6dmysm0000gn/T/python-build.20201116203917.79838
Results logged to /var/folders/fz/v6d_5ykj1x1b8w9c9l6dmysm0000gn/T/python-build.20201116203917.79838.log

Last 10 log lines:
./Modules/posixmodule.c:8210:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
              ^
./Modules/posixmodule.c:10432:5: warning: code will never be executed [-Wunreachable-code]
    Py_FatalError("abort() called from Python code didn't abort!");
    ^~~~~~~~~~~~~
1 warning and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.

対処法

% CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" \
pyenv install --patch 3.6.5 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

とすることでした。3.6.5は、入れたいpythonのバージョンに変えてください。

% CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" \
pyenv install --patch 3.6.5 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.5.tar.xz...
-> https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Installing Python-3.6.5...
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3369 (offset -57 lines).
patching file configure.ac
Hunk #1 succeeded at 495 (offset -15 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.6.5 to /Users/haruka/.pyenv/versions/3.6.5

参考:
Unable to build Python on macOS Big Sur with Xcode 12 beta · Issue #1643 · pyenv/pyenv · GitHub