[英]How to install python on Mac with wide-build
I found that Python on my Mac build with narrow-build which will raise character range error when i use the re model. 我发现我的Mac上的Python使用narrow-build构建,这会在我使用re模型时引发字符范围错误。
So I want to install the wide-build in my Mac.So how can I install Python with wide-build on Mac? 所以我想在我的Mac上安装广泛的版本。那么如何在Mac上安装广泛的Python?
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. 如果你真的需要OS X上的Python 2“广泛构建”来支持
0xffff
以上的Unicode代码点,你可能必须自己从源代码构建它。 Most distributions for OS X that I am aware of use the default "narrow build"; 我所知道的OS X的大多数发行版都使用默认的“narrow build”; one exception is MacPorts which does support a wide-build variant:
一个例外是MacPorts ,它支持广泛构建的变体:
sudo port install python27 +ucs4
To build Python yourself from source, download and unpack the latest Python source tarball and set appropriate configure arguments for your situation. 要从源代码自己构建Python,请下载并解压缩最新的Python源代码tarball,并为您的情况设置适当的configure参数。 The key one is
--enable-unicode=ucs4
. 关键的一个是
--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
As noted by Jason, current Python 3 releases always support all Unicode characters. 正如Jason所指出的,当前的Python 3版本始终支持所有Unicode字符。
If using Python3 upgrade to the latest version. 如果使用Python3升级到最新版本。 In 3.3 and later:
在3.3及更高版本中:
The distinction between narrow and wide Unicode builds is dropped.
忽略了窄版和宽版Unicode之间的区别。
http://legacy.python.org/dev/peps/pep-0393/ http://legacy.python.org/dev/peps/pep-0393/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.