mac
mac 默认的环境是 python 2.X
后来安装了 python3.X 所有的命令使用 python3
来执行。
但是还是有一个问题,pip 默认还是 2.x,这里就需要安装 pip3。
pip3 安装
下载
curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
等待下载完成
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1659k 100 1659k 0 0 7296 0 0:03:52 0:03:52 --:--:-- 13975
安装
- python3
brew install python3
- pip3
python3 get-pip.py
日志如下:
Collecting pip
Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 18.0
Uninstalling pip-18.0:
Successfully uninstalled pip-18.0
Successfully installed pip-19.0.3
验证
$ pip3 --version
pip 19.0.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
测试安装 openccpy
查询
$ pip3 search openccpy
openccpy (0.0.4.2) - Open Chinese Convert is an opensource project for conversion between Traditional Chinese and Simplified Chinese for python.
安装
$ pip3 install openccpy==0.0.4.2
交互命令行测试
>>> from openccpy.opencc import *
>>> print(Opencc.to_simple("一目瞭然"))