Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
690 views
in Technique[技术] by (71.8m points)

macos - 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.

So I want to install the wide-build in my Mac.So how can I install Python with wide-build on Mac?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

As noted by Jason, current Python 3 releases always support all Unicode characters.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...