关于os x编译时提示缺少“Python.h”解决方案

文章首发地址:https://blog.aosan825.top/index.php/archives/5/

emmmm, 今天在编译webots时提示缺少,bing搜到的解决方案有两个:

  1. 直接brew install python
  2. 安装python-devel
    第一个毫无疑问是没有卵用的,每次开始用新系统之前就是用这个命令来安装python,所以选择解决方案2
    关于python-devel安装方法我搜到了两种,一个是直接brew install python-devel(反正我没搜到这个包),另一个是用pyenv来安装。
brew install pyenv
pyenv install 3.7.3

然后报错。。。

python-build: use openssl 1.0 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.3.tar.xz...
-> https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
Installing Python-3.7.3...
python-build: use readline from homebrew

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

Inspect or clean up the working tree at /var/folders/bj/qp1379l545n35gj3q_tk6qkc0000gn/T/python-build.20190411170849.27571
Results logged to /var/folders/bj/qp1379l545n35gj3q_tk6qkc0000gn/T/python-build.20190411170849.27571.log

Last 10 log lines:
  File "/private/var/folders/bj/qp1379l545n35gj3q_tk6qkc0000gn/T/python-build.20190411170849.27571/Python-3.7.3/Lib/ensurepip/__main__.py", line 5, in 
    sys.exit(ensurepip._main())
  File "/private/var/folders/bj/qp1379l545n35gj3q_tk6qkc0000gn/T/python-build.20190411170849.27571/Python-3.7.3/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/bj/qp1379l545n35gj3q_tk6qkc0000gn/T/python-build.20190411170849.27571/Python-3.7.3/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/bj/qp1379l545n35gj3q_tk6qkc0000gn/T/python-build.20190411170849.27571/Python-3.7.3/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

艹(中国语),继续搜索解决方案

xcode-select --install
brew update
brew install pyenv
pyenv install 3.6.3
pyenv global 3.6.3

CSDN上基本都是这个,结果第一条命令就出问题了:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

换搜索引擎,搜到一个日本前辈的博客,给了个解决方案:

$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

执行,问题解决,草(日本语)


更新:发现一个更简单的解决方案,直接安装Python官网的PKG不会出现这个问题。。。。

你可能感兴趣的:(个人学习笔记)