After upgrading from MacOS Mojave to Catalina, numpy can no longer be imported. While improving this situation, at the same time, the Python 2 series was upgraded to 3.7.7 at this opportunity, although support will end in January 2020. I will describe how to do it as a memorandum in this article.
$ python abc.py
Traceback (most recent call last):
File "abc.py", line 3, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
So I tried to install Python 3.7.7, but I got an error.
$ pyenv install 3.7.7
(Omitted)
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
I found a similar case study on different versions of the OS in another Qiita article. Corrective action for "xcrun: error: invalid active developer path (/ Library / Developer / CommandLineTools) ..." after updating macOS
I installed it because I need Xcode Command Line Tools. In my environment, I was able to proceed in the following way.
$ softwareupdate --list
Software Update Tool
Finding available software
Software Update found the following new or updated software:
* Label: Command Line Tools for Xcode-12.1
Title: Command Line Tools for Xcode, Version: 12.1, Size: 431272K, Recommended: YES,
$ softwareupdate --install -a
Software Update Tool
Finding available software
Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
At this time, the version of pyenv is as follows.
$ pyenv --version
pyenv 1.2.17
The .bash_profile contained the following description:
(Omitted)
PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
export PATH=${PYENV_ROOT}/bin:$PATH
eval "$(pyenv init -)"
fi
(Omitted)
I tried installing Python 3.7.7 again, but this time the installation is complete.
$ pyenv install 3.7.7
python-build: use [email protected] from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.7.tar.xz...
-> https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
Installing Python-3.7.7...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.7.7 to /Users/ecru/.pyenv/versions/3.7.7
Check the version of Python installed by pyenv. Then set 3.7.7 to global.
$ pyenv versions
system
* 2.7.17 (set by /Users/ecru/.pyenv/version)
3.7.7
$ pyenv global 3.7.7
$ python -V
Python 3.7.7
Now the error message stating that numpy can't be imported is gone and abc.py can now be run in the terminal.
That's all for the memorandum.
Recommended Posts