如何在Mac上使用宽版本安装python [英] How to install python on Mac with wide-build
问题描述
我发现Mac上的Python使用窄版构建,当我使用re模型时,这会引发字符范围错误.
I found that Python on my Mac build with narrow-build which will raise character range error when i use the re model.
所以我想在Mac上安装Wide-build,那么如何在Mac上安装带有Wide-build的Python?
So I want to install the wide-build in my Mac.So how can I install Python with wide-build on Mac?
推荐答案
如果您确实需要在OS X上广泛构建" Python 2以支持0xffff
以上的Unicode代码点,则可能必须对其进行构建自己从源头上来.我知道的大多数OS X发行版都使用默认的窄版". MacPorts 是一个例外,它确实支持广泛构建的变体:
If you really need a "wide build" of Python 2 on OS X to support Unicode code points above 0xffff
, you'll probably have to build it yourself from source. Most distributions for OS X that I am aware of use the default "narrow build"; one exception is MacPorts which does support a wide-build variant:
sudo port install python27 +ucs4
要从源代码自己构建Python,请下载并解压缩最新的Python源tarball 并进行适当的配置您的情况的论点.关键之一是--enable-unicode=ucs4
.例如,最小配置可能是:
To build Python yourself from source, download and unpack the latest Python source tarball and set appropriate configure arguments for your situation. The key one is --enable-unicode=ucs4
. For example, a minimal configuration might be:
curl -O https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
tar xf ./Python-2.7.8.tgz
cd ./Python-2.7.8
./configure --enable-unicode=ucs4 --prefix=/path/to/install MACOSX_DEPLOYMENT_TARGET=10.9
make
make install
cd
/path/to/install/bin/python2.7
Python 2.7.8 (default, Aug 3 2014, 22:27:28)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxunicode
1114111
Jason指出,当前的Python 3版本始终支持所有Unicode字符.
As noted by Jason, current Python 3 releases always support all Unicode characters.
这篇关于如何在Mac上使用宽版本安装python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!