在python 3.x中安装Pyicu

Install Pyicu in python 3.x

我的系统是Windows 10 x64

现在我想安装pyicu,但遇到了这样的问题

1
Collecting pyicu

使用缓存的pyicu-1.9.7.tar.gz完成命令python setup.py egg_info的输出:回溯(最近一次呼叫的最后一次):文件"c:usersanhvuappdatalocal emppip-build-v5fb9ri4pyicusetup.py",第12行,inicu_version=os.environ['icu_version']文件"c:usersanhvuappdatalocalprogramspythonpython35libos.py",第725行,在getitem中从"无"提升键错误(键)keyror:"ICU版本"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File"C:\Users\ANHVU\AppData\Local\Temp\pip-build-v5fb9ri4\pyicu\setup.py", line 26, in <module>
    ICU_VERSION = check_output(('icu-config', '--version')).strip()
  File"C:\Users\ANHVU\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 316, in check_output
    **kwargs).stdout
  File"C:\Users\ANHVU\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 383, in run
    with Popen(*popenargs, **kwargs) as process:
  File"C:\Users\ANHVU\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File"C:\Users\ANHVU\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 955, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File"<string>", line 1, in <module>
  File"C:\Users\ANHVU\AppData\Local\Temp\pip-build-v5fb9ri4\pyicu\setup.py", line 33, in <module>
    ''')
RuntimeError:
Please set the ICU_VERSION environment variable to the version of
ICU you have installed.

我如何解决这个问题?请帮帮我。


您可以从用于python扩展包的非官方Windows二进制文件下载相应的whl文件。

例如,64位Windows和python3.7的最新版本(截至2019年1月13日)是pyicu?2.2?CP37?CP37米?WiNYAMD64.WHL

然后以管理员身份打开Windows PowerShell控制台,cd到放置whl文件的目录,并执行以下命令:

1
python -m pip install .\PyICU?2.2?cp37?cp37m?win_amd64.whl

或者(如果您已经安装了以前的pyicu版本)

1
python -m pip install -U .\PyICU?2.2?cp37?cp37m?win_amd64.whl