简体   繁体   English

正确安装 PyICU 和 icu4c 时,导入或找不到符号错误与多语言错误

[英]Import or Symbol not Found Error with polyglot when PyICU and icu4c installed correctly

I'm really struggling with polyglot , pyicu and icu4c - and it seems like I'm not the only one...我真的在为polyglotpyicuicu4c苦苦挣扎——而且似乎我不是唯一一个......

I'm running Mac OS High Sierra 10.13.6 and python3 with a virtualenv我正在使用 virtualenv 运行 Mac OS High Sierra 10.13.6和 python3

Here are the steps I've taken, largely based on this article:以下是我采取的步骤,主要基于这篇文章:

  1. Start from a new virtualenv从一个新的 virtualenv 开始
  2. Remove and re-install icu4c (v.62.1) with homebrew使用自制软件删除并重新安装 icu4c (v.62.1)
  3. Check ICU_VERSION is "62.1"检查 ICU_VERSION 是“62.1”
  4. Do ln -s /usr/local/Cellar/icu4c/62.1/bin/icu-config /usr/local/bin/icu-configln -s /usr/local/Cellar/icu4c/62.1/bin/icu-config /usr/local/bin/icu-config
  5. Download the pyicu tar file (2.1)下载pyicu tar文件(2.1)
  6. Extract pyicu and edit setup.py as indicated in the linked article提取 pyicu 并按照链接文章中的指示编辑 setup.py
  7. build and install pyicu构建和安装pyicu

I see:我懂了:

    Adding CXXFLAGS="-std=c++11 -I/usr/local/Cellar/icu4c/62.1/include" from /usr/local/bin/icu-config
    Adding LDFLAGS="-L/usr/local/Cellar/icu4c/62.1/lib -licui18n -licuuc -licudata" from /usr/local/bin/icu-config                    
    Installed/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyICU-2.1-py3.6-macosx-10.6-intel.egg
    ...
    Processing dependencies for PyICU==2.1
    Finished processing dependencies for PyICU==2.1

as expected.正如预期的那样。

  1. pip3 install polyglot pip3 安装多语言

when I run my script I get the following:当我运行我的脚本时,我得到以下信息:

File "/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/polyglot/detect/__init__.py", line 1, in <module>
from .base import Detector, Language
File "/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/polyglot/detect/base.py", line 11, in <module>
from icu import Locale
ModuleNotFoundError: No module named 'icu'

Unsurprising because there isn't actually an icu module in PATH.不足为奇,因为 PATH 中实际上没有 icu 模块。

If, instead of steps 5-7 I do pip3 install pyicu (which creates the icu folder), I get:如果我执行 pip3 install pyicu (创建 icu 文件夹)而不是步骤 5-7,我会得到:

ImportError: dlopen(/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so, 2): Symbol not found: __ZNK6icu_6214Transliterator12getTargetSetERNS_10UnicodeSetE
Referenced from: /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so

output from otool -L /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so is: otool -L /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so输出是:

/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)

Very grateful for any pointers you can offer.非常感谢您提供的任何指示。

Thanks谢谢

This answer on Github was not meant for this error specifically but provides a simple means for installing polyglot using conda and Python 3.6 (after solving the icu error I cam across others so this was helpful). Github 上的这个答案并不是专门针对这个错误,而是提供了一种使用 conda 和 Python 3.6 安装多语言的简单方法(在解决了 icu 错误后,我遇到了其他人,所以这很有帮助)。

https://github.com/aboSamoor/polyglot/issues/80#issuecomment-417863726 https://github.com/aboSamoor/polyglot/issues/80#issuecomment-417863726

Using a conda env you do the following:使用 conda env 执行以下操作:

conda install -c conda-forge pyicu morfessor icu -y && pip install pycld2 polyglot

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尽管pyicu已正确安装,但Mac和Ubuntu中icu的导入错误 - Import error for icu in Mac and Ubuntu, although pyicu is installed correctly 尝试安装PyICU时出现FileNotFoundError - FileNotFoundError when trying to install PyICU 验证tensorflow正确安装时出错 - Error when verifying tensorflow installed correctly Tkcalendar 安装正确但仍然出现“找不到模块”错误 - Tkcalendar installed correctly but still gives 'module not found' error 在Python 3.6中调用C ++扩展时,导入错误“未定义符号:_ZNK9FastNoise8GetNoiseEff” - Import error “undefined symbol: _ZNK9FastNoise8GetNoiseEff” when calling C++ extension in Python 3.6 python 软件包未通过 CI/CD 管道安装,导入错误,未找到 package - python packages are not installed throughCI/CD pipelines,import error , package not found 错误:尝试导入 pyarrow/feather 时出现“未定义符号” - Error: “Undefined symbol” when trying to import pyarrow/feather 无法导入 PyAudio C 模块“_portaudio”。 (Mac M1),关于找不到符号:_PaMacCore_SetupChannelMap - Could not import the PyAudio C module '_portaudio'. (Mac M1), about Symbol not found: _PaMacCore_SetupChannelMap MiniConda中的“找不到命令&#39;import&#39;,但可以安装” - “Command 'import' not found, but can be installed with” in MiniConda C ++ Python模块导入错误:“undefined symbol:Py_InitModule3”(Py_InitModule()) - C++ Python module import error: “undefined symbol: Py_InitModule3” ( Py_InitModule () )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM