尝试在Python 3.6.6
上使用Airflow
安装PyEnv
(针对MacOS
)时,我遇到构建失败,并显示以下堆栈跟踪
文件 “ /private/var/folders/6y/kf699bqj2sgcgjshb20fr5zh0000gn/T/python-build.20180721180716.86347/Python-3.6.6/Lib/xmlrpc/client.py”, 第138行,在 从xml.parsers导入expat文件“ /private/var/folders/6y/kf699bqj2sgcgjshb20fr5zh0000gn/T/python-build.20180721180716.86347/Python-3.6.6/Lib/xml/parsers/expat.py”, 第4行 从pyexpat导入* ModuleNotFoundError:没有名为“ pyexpat”的模块进行制造:*** [安装]错误1
构建失败(使用python-build 20180424的OS X 10.13.6)
在以下位置检查或清理工作树 /var/folders/6y/kf699bqj2sgcgjshb20fr5zh0000gn/T/python-build.20180721180716.86347 结果记录到/ var / folders / 6y / kf699bqj2sgcgjsh
我已经按照setting-up PyEnv
on Mac
via Homebrew
文档中提到的步骤进行操作。
环境/框架版本
MacOS High Sierra 10.13.6
Homebrew 1.7.1
PyEnv 1.2.6
Python
个分配
Python 2.7.15 [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Python 3.7.0 [Clang 9.0.0 (clang-900.0.39.2)] on darwin
答案 0 :(得分:8)
被接受的答案对我不起作用(莫哈韦沙漠),但这确实有效:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
贷记http://www.blog.howechen.com/macos-mojave-pyenv-install-multi-version-build-failed-solution/
答案 1 :(得分:7)
我唯一能使它工作的方法是在安装之前通过以下前缀
CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include
-I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 3.7.1
答案 2 :(得分:5)
我能够通过参考Common build problems
来避免上述错误brew install readline xz
xcode-select --install
brew install openssl
此后,我安装并初始化 pyenv
brew install pyenv
pyenv init
(在您的项目目录内)最后安装并激活所需的python
版本
pyenv local 3.6.6
(在您的项目目录内)这是thread #1188到GitHub
上原始@Harry Moreno的链接
答案 3 :(得分:4)
我在Mojave和Python 3.7.3中遇到了这个问题。
这对我有用:
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk MACOSX_DEPLOYMENT_TARGET=10.14 pyenv install 3.7.3
答案 4 :(得分:3)
安装 Xcode:
xcode-select --install
安装 Brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
或
更新酿造:
brew upgrade
安装软件包:
brew install libxml2
brew install libxslt
brew link libxml2 --force
brew link libxslt --force
安装 Pyenv
curl https://pyenv.run | bash
在 .bashrc/.zshrc 配置文件中插入以下几行:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
重启终端并执行:
pyenv install 3.6.5
如果还是不行: (只需将 python 版本更改为所需的版本 - 就我而言,我已将 python 3.6.5 安装到 pyenv)
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)
答案 5 :(得分:1)
简短答案:
$ brew upgrade
现在您可以尝试通过pyenv安装python
$ pyenv install 3.7.4
然后,您必须设置python路径
pyenv global 3.7.4
现在,关闭并打开一个新终端,并编写命令
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
仅此而已。对我来说很好。
答案 6 :(得分:0)
BUILD FAILED (OS X 10.14.3 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745
Results logged to /var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745.log
Last 10 log lines:
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__init__.py", line 204, in _main
default_pip=args.default_pip,
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__init__.py", line 117, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/private/var/folders/kt/79hj2dxs5vg7gsy188n6tk9c0000gn/T/python-build.20190226112205.71745/Python-3.6.6/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip._internal
我找到了解决方案 http://digidememory.blogspot.com/2019/01/macos-mojave-10142python371.html
对于我来说,我通过此命令解决了
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
答案 7 :(得分:0)
在我的情况下,这是由于数据从旧Mac迁移到新Mac引起的。 Xcode命令行工具和Homebrew均已迁移,但出现了问题。从头开始重新安装它们对我有用。
重新安装CLI工具:
$ sudo rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install
重新安装和更新Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
Istall pyenv +软件包和python 3:
brew install pyenv
brew install openssl readline sqlite3 xz zlib
pyenv install 3.7.5
答案 8 :(得分:0)
升级到 Big Sur 后,您需要重新安装 X Code 工具。即使你以前做过
<块引用>xcode-select --install
这对我有用
如果这不起作用,请强制重置
<块引用>sudo xcode-select --reset
可以在此处找到更多详细信息:https://dev.to/o9uzdev/macos-xcrun-error-invalid-active-developer-path-missing-xcrun-411a
答案 9 :(得分:0)
尝试以下任一方法:
❯ xcode-select --install
❯ xcode-select --reset
❯ export SDKROOT="macosx"
Maybe you don't have command line tools installed.
Or maybe you messed up the $DEVELOPER_DIR environment
variable path.
Or maybe your compiling with command line tools meant
for iPhone development or WatchOS !?!
❯ brew update && brew upgrade pyenv
Maybe your command versions aren't up to date ?
Double check you've properly followed the installation
steps for your version, OS and shell.
❯ brew install make cmake;
❯ export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
Maybe you don't have `make` and `cmake` build/compilation commands.
Or maybe they can't be found.
❯ brew install openssl readline tcl-tk sqlite3 xz zlib bzip2;
❯ export PATH="/usr/local/opt/bzip2/bin:$PATH";
export CPPFLAGS="\
-I$(xcrun --show-sdk-path)/usr/include \
-I$(brew --prefix openssl)/include \
-I$(brew --prefix readline)/include \
-I$(brew --prefix zlib)/include \
-I$(brew --prefix bzip2)/include";
export LDFLAGS="\
-L$(xcrun --show-sdk-path)/usr/lib \
-L$(brew --prefix openssl)/lib \
-L$(brew --prefix readline)/lib \
-L$(brew --prefix zlib)/lib \
-L$(brew --prefix bzip2)/lib";
Maybe you're missing some suggested `pyenv` build,
tools or what not. Or maybe they can't be found during
compilation.
https://github.com/pyenv/pyenv/wiki#suggested-build-environment
❯ unset LIBRARY
Maybe you've set/defined a LIBRARY environment variable
(either in your shell initialization/startup files,
e.g. .bashrc, .zshrc, etc; or shell session).
This can be bad because it could be used in the build/compilation
process and may crash it.
❯ pyenv install --verbose --patch 3.8.11 \
< <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Maybe you haven't heard of the magical patch yet ?
which fixes issue with build process not taking into
account certain MacOS versions.
Also using the `--verbose` option, might give you
better hints as to what's going wrong.
❯ pyenv global 3.8.11 && eval "$(pyenv init -)"
OR
❯ pyenv global 3.8.11 && exec $SHELL --login
Also, don't forget to set your preferred global
python interpreter version and reinitialize `pyenv`
or restart your [login] shell altogether.
它可能仍然不起作用,在这种情况下,请继续查找并在找到答案后发布。最好的祝福。
以下是我查阅过的一些资源:
答案 10 :(得分:0)
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.12 < <(curl -sSL
https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
更改您想要的版本
答案 11 :(得分:0)
我正在为那些试图在 2021 年解决此问题的人发布我的解决方案。我使用的是 macOS Big Sur 版本 11.5.1。对我来说,这有效:
卸载旧工具
$ sudo rm -rf /Library/Developer/CommandLineTools
重新安装 Xcode 命令行工具
$ xcode-select --install
使用pyenv安装python
$ pyenv 安装 3.9.5
答案 12 :(得分:-4)
这对我有用: