undertheseanlp / underthesea

Underthesea - Vietnamese NLP Toolkit
http://undertheseanlp.com
GNU General Public License v3.0
1.37k stars 270 forks source link

Cannot import underthesea 6.2.0 on macOS 10.11 with Python 3.9.16 #677

Open BLKSerene opened 1 year ago

BLKSerene commented 1 year ago

Hi, when trying to import underthesea 6.2.0 on macOS 10.11 with Python 3.9.16, it shows the following errors:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/__init__.py", line 37, in <module>
    from .pipeline.text_normalize import text_normalize
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/pipeline/text_normalize/__init__.py", line 2, in <module>
    from underthesea.pipeline.word_tokenize.regex_tokenize import tokenize
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/pipeline/word_tokenize/__init__.py", line 3, in <module>
    from .model import CRFModel
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/pipeline/word_tokenize/model.py", line 4, in <module>
    from underthesea_core import CRFFeaturizer
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea_core.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea_core.cpython-39-darwin.so: cannot load 'underthesea_core.cpython-39-darwin.so' (load command 0x80000034 is unknown)

If downgrade to underthesea 6.1.1, everything is OK.

rain1024 commented 1 year ago

@BLKSerene Please show me how you install and the commands you used.

I can run underthese 6.2.0 on MacOS 12.6.3 with Python 3.9.16 normally.

Screen Shot 2023-03-20 at 09 23 21

My environement

Screen Shot 2023-03-20 at 09 23 55
(test39) anhv:~ anhv$ sw_vers
ProductName:    macOS
ProductVersion: 12.6.3
BuildVersion:   21G419
BLKSerene commented 1 year ago

@rain1024 I simply run pip3 install --upgrade underthesea to upgrade underthesea to the latest version (currently 6.2.0) on OS X 10.11 (uninstalling underthesea first and then reinstalling it does not fix the issue, downgrading to 6.1.1 works).

The errors occurred upon: import underthesea which means no functions could be used with underthesea 6.2.0 / Python 3.9.16 on OS X 10.11.

I did not test it on newer macOSes. This issue might be related to old macOS/OS X only.

rain1024 commented 1 year ago

@BLKSerene

... underthesea_core.cpython-39-darwin.so: cannot load 'underthesea_core.cpython-39-darwin.so'

I simply run pip3 install --upgrade underthesea

I think this issue is related with underthsea_core, I upgrade underthesea_core to 1.0.0 in underthesea==6.2.0

Can you give me the result when you run pip freeze in your environement

BLKSerene commented 1 year ago

@rain1024

altgraph==0.17.3
beautifulsoup4==4.11.2
blis==0.7.9
botok==0.8.10
ca-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/ca_core_news_sm-3.5.0-py3-none-any.whl
catalogue==2.0.8
certifi==2022.12.7
charset-normalizer==3.1.0
click==8.1.3
confection==0.0.4
contourpy==1.0.7
cycler==0.11.0
cymem==2.0.7
da-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/da_core_news_sm-3.5.0-py3-none-any.whl
DAWG-Python==0.7.2
de-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/de_core_news_sm-3.5.0-py3-none-any.whl
docopt==0.6.2
el-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/el_core_news_sm-3.5.0-py3-none-any.whl
en-core-web-sm @ file:///Users/blkserene/Desktop/spacy_models/en_core_web_sm-3.5.0-py3-none-any.whl
es-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/es_core_news_sm-3.5.0-py3-none-any.whl
et-xmlfile==1.1.0
fi-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/fi_core_news_sm-3.5.0-py3-none-any.whl
fonttools==4.39.2
fr-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/fr_core_news_sm-3.5.0-py3-none-any.whl
hr-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/hr_core_news_sm-3.5.0-py3-none-any.whl
idna==3.4
install==1.3.5
it-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/it_core_news_sm-3.5.0-py3-none-any.whl
ja-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/ja_core_news_sm-3.5.0-py3-none-any.whl
jieba==0.42.1
Jinja2==3.1.2
joblib==1.2.0
kiwisolver==1.4.4
langcodes==3.3.0
lingua-language-detector==1.3.2
lt-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/lt_core_news_sm-3.5.0-py3-none-any.whl
lxml==4.9.2
macholib==1.16.2
MarkupSafe==2.1.2
matplotlib==3.5.3
mk-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/mk_core_news_sm-3.5.0-py3-none-any.whl
murmurhash==1.0.9
nb-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/nb_core_news_sm-3.5.0-py3-none-any.whl
networkx==3.0
nl-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/nl_core_news_sm-3.5.0-py3-none-any.whl
nltk==3.8.1
numpy==1.24.2
opencc-python-reimplemented==0.1.7
openpyxl==3.1.2
packaging==23.0
pathy==0.10.1
Pillow==9.4.0
pl-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/pl_core_news_sm-3.5.0-py3-none-any.whl
preshed==3.0.8
pt-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/pt_core_news_sm-3.5.0-py3-none-any.whl
pydantic==1.10.6
pyinstaller @ file:///Users/blkserene/Desktop/Wordless/utils/pyinstaller-5.9.0_modified.zip
pyinstaller-hooks-contrib==2023.1
pymorphy3==1.2.0
pymorphy3-dicts-ru==2.4.417150.4580142
pymorphy3-dicts-uk==2.4.1.1.1663094765
pyparsing==3.0.9
pypdf==3.6.0
pyphen==0.14.0
PyQt5==5.10
pythainlp==3.1.1
python-crfsuite==0.9.9
python-dateutil==2.8.2
python-docx==0.8.11
python-mecab-ko==1.3.3
python-mecab-ko-dic==2.1.1.post2
PyYAML==6.0
regex==2022.10.31
requests==2.28.2
ro-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/ro_core_news_sm-3.5.0-py3-none-any.whl
ru-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/ru_core_news_sm-3.5.0-py3-none-any.whl
sacremoses==0.0.53
scikit-learn==1.2.2
scipy==1.10.1
simplemma==0.9.1
sip==4.19.25
six==1.16.0
smart-open==6.3.0
soupsieve==2.4
spacy==3.5.1
spacy-legacy==3.0.12
spacy-loggers==1.0.4
spacy-lookups-data==1.0.3
spacy-pkuseg==0.0.32
srsly==2.4.6
SudachiDict-core==20230110
SudachiPy==0.6.7
sv-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/sv_core_news_sm-3.5.0-py3-none-any.whl
textblob==0.17.1
thinc==8.1.9
threadpoolctl==3.1.0
tqdm==4.65.0
typer==0.7.0
typing_extensions==4.5.0
uk-core-news-sm @ file:///Users/blkserene/Desktop/spacy_models/uk_core_news_sm-3.5.0-py3-none-any.whl
underthesea==6.1.1
underthesea_core==0.0.5a2
urllib3==1.26.15
wasabi==1.1.1
wordcloud==1.8.2.2
zh-core-web-sm @ file:///Users/blkserene/Desktop/spacy_models/zh_core_web_sm-3.5.0-py3-none-any.whl
rain1024 commented 1 year ago

@BLKSerene Please run

pip3 install --upgrade underthesea
pip3 install --upgrade underthesea_core

and make sure your package will be

underthesea==6.2.0
underthesea_core==1.0.0

I think it will works well.

On way to test it is you can create new seperated environement (with venv or conda) and install underthesea with

pip install underthesea==6.2.0
BLKSerene commented 1 year ago

@rain1024 I tried setting up a clean virtual environment and install only the latest version of underthesea and underthesea_core. All installations are OK, but it does not work on import.

BLKSerenes-Mac:1 blkserene$ python3 -m venv .venv
BLKSerenes-Mac:1 blkserene$ source .venv/bin/activate

(.venv) BLKSerenes-Mac:1 blkserene$ python3 -m pip install --upgrade pip
Requirement already satisfied: pip in ./.venv/lib/python3.9/site-packages (22.0.4)
Collecting pip
  Downloading pip-23.0.1-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 5.7 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.4
    Uninstalling pip-22.0.4:
      Successfully uninstalled pip-22.0.4
Successfully installed pip-23.0.1
(.venv) BLKSerenes-Mac:1 blkserene$ pip3 install --upgrade setuptools
Requirement already satisfied: setuptools in ./.venv/lib/python3.9/site-packages (58.1.0)
Collecting setuptools
  Downloading setuptools-67.6.0-py3-none-any.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 1.7 MB/s eta 0:00:00
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 58.1.0
    Uninstalling setuptools-58.1.0:
      Successfully uninstalled setuptools-58.1.0
Successfully installed setuptools-67.6.0

(.venv) BLKSerenes-Mac:1 blkserene$ pip3 list
Package    Version
---------- -------
pip        23.0.1
setuptools 67.6.0

(.venv) BLKSerenes-Mac:1 blkserene$ pip3 install underthesea
Collecting underthesea
  Downloading underthesea-6.2.0-py3-none-any.whl (19.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.2/19.2 MB 7.1 MB/s eta 0:00:00
Collecting python-crfsuite>=0.9.6
  Downloading python_crfsuite-0.9.9-cp39-cp39-macosx_10_9_x86_64.whl (183 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 183.6/183.6 kB 22.2 MB/s eta 0:00:00
Collecting joblib
  Downloading joblib-1.2.0-py3-none-any.whl (297 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 298.0/298.0 kB 8.7 MB/s eta 0:00:00
Collecting PyYAML
  Downloading PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl (197 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 197.6/197.6 kB 7.9 MB/s eta 0:00:00
Collecting Click>=6.0
  Downloading click-8.1.3-py3-none-any.whl (96 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 kB 6.5 MB/s eta 0:00:00
Collecting tqdm
  Downloading tqdm-4.65.0-py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 kB 5.4 MB/s eta 0:00:00
Collecting scikit-learn
  Downloading scikit_learn-1.2.2-cp39-cp39-macosx_10_9_x86_64.whl (9.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.1/9.1 MB 6.0 MB/s eta 0:00:00
Collecting underthesea-core==1.0.0
  Downloading underthesea_core-1.0.0-cp39-cp39-macosx_10_7_x86_64.whl (542 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 542.1/542.1 kB 6.8 MB/s eta 0:00:00
Collecting requests
  Downloading requests-2.28.2-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 6.3 MB/s eta 0:00:00
Collecting nltk
  Downloading nltk-3.8.1-py3-none-any.whl (1.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 6.8 MB/s eta 0:00:00
Collecting regex>=2021.8.3
  Downloading regex-2022.10.31-cp39-cp39-macosx_10_9_x86_64.whl (293 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 293.9/293.9 kB 6.3 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_x86_64.whl (124 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 124.7/124.7 kB 8.7 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 6.4 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 7.9 MB/s eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.9/140.9 kB 7.0 MB/s eta 0:00:00
Collecting scipy>=1.3.2
  Downloading scipy-1.10.1-cp39-cp39-macosx_10_9_x86_64.whl (35.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 35.2/35.2 MB 4.9 MB/s eta 0:00:00
Collecting numpy>=1.17.3
  Downloading numpy-1.24.2-cp39-cp39-macosx_10_9_x86_64.whl (19.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.8/19.8 MB 7.4 MB/s eta 0:00:00
Collecting threadpoolctl>=2.0.0
  Downloading threadpoolctl-3.1.0-py3-none-any.whl (14 kB)
Installing collected packages: underthesea-core, python-crfsuite, urllib3, tqdm, threadpoolctl, regex, PyYAML, numpy, joblib, idna, Click, charset-normalizer, certifi, scipy, requests, nltk, scikit-learn, underthesea
Successfully installed Click-8.1.3 PyYAML-6.0 certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 joblib-1.2.0 nltk-3.8.1 numpy-1.24.2 python-crfsuite-0.9.9 regex-2022.10.31 requests-2.28.2 scikit-learn-1.2.2 scipy-1.10.1 threadpoolctl-3.1.0 tqdm-4.65.0 underthesea-6.2.0 underthesea-core-1.0.0 urllib3-1.26.15

(.venv) BLKSerenes-Mac:1 blkserene$ pip3 install --upgrade underthesea_core
Requirement already satisfied: underthesea_core in ./.venv/lib/python3.9/site-packages (1.0.0)
(.venv) BLKSerenes-Mac:1 blkserene$ pip3 install --upgrade underthesea
Requirement already satisfied: underthesea in ./.venv/lib/python3.9/site-packages (6.2.0)
Requirement already satisfied: nltk in ./.venv/lib/python3.9/site-packages (from underthesea) (3.8.1)
Requirement already satisfied: PyYAML in ./.venv/lib/python3.9/site-packages (from underthesea) (6.0)
Requirement already satisfied: python-crfsuite>=0.9.6 in ./.venv/lib/python3.9/site-packages (from underthesea) (0.9.9)
Requirement already satisfied: underthesea-core==1.0.0 in ./.venv/lib/python3.9/site-packages (from underthesea) (1.0.0)
Requirement already satisfied: joblib in ./.venv/lib/python3.9/site-packages (from underthesea) (1.2.0)
Requirement already satisfied: tqdm in ./.venv/lib/python3.9/site-packages (from underthesea) (4.65.0)
Requirement already satisfied: scikit-learn in ./.venv/lib/python3.9/site-packages (from underthesea) (1.2.2)
Requirement already satisfied: requests in ./.venv/lib/python3.9/site-packages (from underthesea) (2.28.2)
Requirement already satisfied: Click>=6.0 in ./.venv/lib/python3.9/site-packages (from underthesea) (8.1.3)
Requirement already satisfied: regex>=2021.8.3 in ./.venv/lib/python3.9/site-packages (from nltk->underthesea) (2022.10.31)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.venv/lib/python3.9/site-packages (from requests->underthesea) (1.26.15)
Requirement already satisfied: idna<4,>=2.5 in ./.venv/lib/python3.9/site-packages (from requests->underthesea) (3.4)
Requirement already satisfied: certifi>=2017.4.17 in ./.venv/lib/python3.9/site-packages (from requests->underthesea) (2022.12.7)
Requirement already satisfied: charset-normalizer<4,>=2 in ./.venv/lib/python3.9/site-packages (from requests->underthesea) (3.1.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in ./.venv/lib/python3.9/site-packages (from scikit-learn->underthesea) (3.1.0)
Requirement already satisfied: numpy>=1.17.3 in ./.venv/lib/python3.9/site-packages (from scikit-learn->underthesea) (1.24.2)
Requirement already satisfied: scipy>=1.3.2 in ./.venv/lib/python3.9/site-packages (from scikit-learn->underthesea) (1.10.1)

(.venv) BLKSerenes-Mac:1 blkserene$ pip3 freeze
certifi==2022.12.7
charset-normalizer==3.1.0
click==8.1.3
idna==3.4
joblib==1.2.0
nltk==3.8.1
numpy==1.24.2
python-crfsuite==0.9.9
PyYAML==6.0
regex==2022.10.31
requests==2.28.2
scikit-learn==1.2.2
scipy==1.10.1
threadpoolctl==3.1.0
tqdm==4.65.0
underthesea==6.2.0
underthesea_core==1.0.0
urllib3==1.26.15

(.venv) BLKSerenes-Mac:1 blkserene$ python3
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23) 
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import underthesea
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/blkserene/Desktop/1/.venv/lib/python3.9/site-packages/underthesea/__init__.py", line 37, in <module>
    from .pipeline.text_normalize import text_normalize
  File "/Users/blkserene/Desktop/1/.venv/lib/python3.9/site-packages/underthesea/pipeline/text_normalize/__init__.py", line 2, in <module>
    from underthesea.pipeline.word_tokenize.regex_tokenize import tokenize
  File "/Users/blkserene/Desktop/1/.venv/lib/python3.9/site-packages/underthesea/pipeline/word_tokenize/__init__.py", line 3, in <module>
    from .model import CRFModel
  File "/Users/blkserene/Desktop/1/.venv/lib/python3.9/site-packages/underthesea/pipeline/word_tokenize/model.py", line 4, in <module>
    from underthesea_core import CRFFeaturizer
ImportError: dlopen(/Users/blkserene/Desktop/1/.venv/lib/python3.9/site-packages/underthesea_core.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /Users/blkserene/Desktop/1/.venv/lib/python3.9/site-packages/underthesea_core.cpython-39-darwin.so: cannot load 'underthesea_core.cpython-39-darwin.so' (load command 0x80000034 is unknown)
rain1024 commented 1 year ago

@BLKSerene

Thanks for submitting your report.

After taking a look at the error log, it seems like the issue is with underthesea_core.cpython-39-darwin.so. I think it might be similar to the problem discussed in this link: https://github.com/huggingface/tokenizers/issues/712 and https://github.com/home-assistant/core/issues/74632 (https://github.com/ijl/orjson/issues/276). By the way, I use Rust to build underthesea_core too.

In my machine, site-packages folder has underthesea_core.cpython-39-darwin.so file

$ ls /Users/anhv/anaconda3/envs/test39/lib/python3.9/site-packages/ | grep underthesea_core
underthesea_core-1.0.0.dist-info
underthesea_core.cpython-39-darwin.so

I will conduct further investigation into this issue at a later time.

rain1024 commented 1 year ago

@BLKSerene may be it related to #685

Please check with our latest version 6.5.0

BLKSerene commented 1 year ago

@rain1024 Unfortunely, after upgrading to Underthesea 6.5.0, it still does not work on OS X 10.11:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/__init__.py", line 37, in <module>
    from .pipeline.text_normalize import text_normalize
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/pipeline/text_normalize/__init__.py", line 2, in <module>
    from underthesea.pipeline.word_tokenize.regex_tokenize import tokenize
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/pipeline/word_tokenize/__init__.py", line 3, in <module>
    from .model import CRFModel
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea/pipeline/word_tokenize/model.py", line 4, in <module>
    from underthesea_core import CRFFeaturizer
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea_core.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/underthesea_core.cpython-39-darwin.so: cannot load 'underthesea_core.cpython-39-darwin.so' (load command 0x80000034 is unknown)

Note: I ran macOS 10.11 on my x64-based computer, so it has nothing to do with ARM.

BLKSerene commented 1 year ago

@rain1024 Here are some updates after my investigation and hope it would help a bit. I suspect the problem lies in the fact that the Rust version you've used to build underthesea_core does not fully support macOS far back to El Capitan 10.11, since I've met the same issue with pydantic v2 which introduced pydantic_core that is also written in Rust.

Although the official documentation lists macOS 10.7+ as the tier-1 support and "guaranteed to work", it seems that the development team does not have the CI resource to test them actively, as discussed in https://github.com/rust-lang/release-team/issues/2 and https://github.com/rust-lang/compiler-team/issues/556.

So, is it possible for you to use an older version of Rust to build underthesea_core which might work properly on older macOSes such as El Capitan 10.11, though there are no information about exactly which version would work?...

Or, is it possible to cross-compile Rust libraries to target at older macOSes (I don't use Rust, so I'm not sure)?

rain1024 commented 1 year ago

@BLKSerene Thank you for looking into this. It's quite the tale!

It reminds me to same issue #530 (when I try to support old version of CentOS)

I'll certainly look into it later.

BLKSerene commented 11 months ago

More updates:

I downloaded the source codes of underthesea-core 1.0.4 from PyPI and installed maturin to build wheel from source on OS X 10.11 with Python 3.10.11, then installed the compiled wheel of underthesea-core manually and upgrade underthesea via pip3 install --upgrade underthesea. Now no errors on importing underthesea and everything seem to work.

Since compiling from source works, I suppose that the codes are fine and the issue lies in the way the wheel targeting macOS 10.7 is built.

BLKSerenes-Mac:underthesea_core-1.0.4 blkserene$ maturin build
    Updating crates.io index
  Downloaded array-init v2.1.0
  Downloaded atty v0.2.14
  Downloaded aho-corasick v1.1.1
  Downloaded bstr v1.6.2
  Downloaded bstr v0.2.17
  Downloaded bumpalo v3.14.0
  Downloaded cast v0.3.0
  Downloaded clap v2.34.0
  Downloaded cqdb v0.5.8
  Downloaded crfs v0.1.3
  Downloaded criterion v0.3.6
  Downloaded criterion-plot v0.4.5
  Downloaded crossbeam-deque v0.8.3
  Downloaded crossbeam-epoch v0.9.15
  Downloaded crossbeam-utils v0.8.16
  Downloaded half v1.8.2
  Downloaded hermit-abi v0.1.19
  Downloaded indoc v0.3.6
  Downloaded indoc-impl v0.3.6
  Downloaded instant v0.1.12
  Downloaded js-sys v0.3.64
  Downloaded jhash v0.1.1
  Downloaded libc v0.2.148
  Downloaded log v0.4.20
  Downloaded memchr v2.6.3
  Downloaded memoffset v0.9.0
  Downloaded num-traits v0.2.16
  Downloaded oorandom v11.1.3
  Downloaded parking_lot v0.11.2
  Downloaded parking_lot_core v0.8.6
  Downloaded paste v0.1.18
  Downloaded paste-impl v0.1.18
  Downloaded plotters v0.3.5
  Downloaded plotters-backend v0.3.5
  Downloaded plotters-svg v0.3.5
  Downloaded proc-macro2 v1.0.67
  Downloaded proc-macro-hack v0.5.20+deprecated
  Downloaded pyo3 v0.15.2
  Downloaded pyo3-build-config v0.15.2
  Downloaded pyo3-macros v0.15.2
  Downloaded pyo3-macros-backend v0.15.2
  Downloaded rayon v1.8.0
  Downloaded rayon-core v1.12.0
  Downloaded redox_syscall v0.2.16
  Downloaded regex v1.9.5
  Downloaded regex-automata v0.1.10
  Downloaded regex-automata v0.3.8
  Downloaded regex-syntax v0.7.5
  Downloaded same-file v1.0.6
  Downloaded serde v1.0.188
  Downloaded serde_derive v1.0.188
  Downloaded serde_cbor v0.11.2
  Downloaded serde_json v1.0.107
  Downloaded smallvec v1.11.1
  Downloaded syn v2.0.37
  Downloaded textwrap v0.11.0
  Downloaded tinytemplate v1.2.1
  Downloaded unicode-ident v1.0.12
  Downloaded unicode-width v0.1.11
  Downloaded walkdir v2.4.0
  Downloaded wasm-bindgen v0.2.87
  Downloaded wasm-bindgen-backend v0.2.87
  Downloaded wasm-bindgen-macro v0.2.87
  Downloaded wasm-bindgen-macro-support v0.2.87
  Downloaded wasm-bindgen-shared v0.2.87
  Downloaded winapi-util v0.1.6
  Downloaded web-sys v0.3.64
  Downloaded 67 crates (6.6 MB) in 16.92s
🔗 Found pyo3 bindings
🐍 Found CPython 3.10 at /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
💻 Using `MACOSX_DEPLOYMENT_TARGET=10.7` for x86_64-apple-darwin by default
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.67
   Compiling unicode-ident v1.0.12
   Compiling cfg-if v1.0.0
   Compiling scopeguard v1.2.0
   Compiling proc-macro-hack v0.5.20+deprecated
   Compiling pyo3-build-config v0.15.2
   Compiling quote v1.0.33
   Compiling memchr v2.6.3
   Compiling syn v1.0.109
   Compiling memoffset v0.9.0
   Compiling crossbeam-utils v0.8.16
   Compiling once_cell v1.18.0
   Compiling crossbeam-epoch v0.9.15
   Compiling libc v0.2.148
   Compiling lock_api v0.4.10
   Compiling parking_lot_core v0.8.6
   Compiling instant v0.1.12
   Compiling smallvec v1.11.1
   Compiling rayon-core v1.12.0
   Compiling unindent v0.1.11
   Compiling pyo3-macros-backend v0.15.2
   Compiling indoc-impl v0.3.6
   Compiling crossbeam-deque v0.8.3
   Compiling paste-impl v0.1.18
   Compiling pyo3 v0.15.2
   Compiling aho-corasick v1.1.1
   Compiling bstr v1.6.2
   Compiling syn v2.0.37
   Compiling jhash v0.1.1
   Compiling bitflags v1.3.2
   Compiling regex-syntax v0.7.5
   Compiling array-init v2.1.0
   Compiling serde v1.0.188
   Compiling lazy_static v1.4.0
   Compiling regex-automata v0.1.10
   Compiling bstr v0.2.17
   Compiling cqdb v0.5.8
   Compiling serde_derive v1.0.188
   Compiling regex-automata v0.3.8
   Compiling paste v0.1.18
   Compiling parking_lot v0.11.2
   Compiling indoc v0.3.6
   Compiling pyo3-macros v0.15.2
   Compiling either v1.9.0
   Compiling rayon v1.8.0
   Compiling regex v1.9.5
   Compiling crfs v0.1.3
   Compiling underthesea_core v1.0.4 (/Users/blkserene/Desktop/underthesea_core-1.0.4)
    Finished dev [unoptimized + debuginfo] target(s) in 34.82s
📦 Built wheel for CPython 3.10 to /Users/blkserene/Desktop/underthesea_core-1.0.4/target/wheels/underthesea_core-1.0.4-cp310-cp310-macosx_10_7_x86_64.whl
BLKSerenes-Mac:underthesea_core-1.0.4 blkserene$ pip3 install /Users/blkserene/Desktop/underthesea_core-1.0.4/target/wheels/underthesea_core-1.0.4-cp310-cp310-macosx_10_7_x86_64.whl

Processing ./target/wheels/underthesea_core-1.0.4-cp310-cp310-macosx_10_7_x86_64.whl
Installing collected packages: underthesea-core
  Attempting uninstall: underthesea-core
    Found existing installation: underthesea_core 0.0.5a2
    Uninstalling underthesea_core-0.0.5a2:
      Successfully uninstalled underthesea_core-0.0.5a2
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
underthesea 6.1.1 requires underthesea-core==0.0.5a2, but you have underthesea-core 1.0.4 which is incompatible.
Successfully installed underthesea-core-1.0.4

BLKSerenes-Mac:underthesea_core-1.0.4 blkserene$ pip3 install underthesea --upgrade
Requirement already satisfied: underthesea in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (6.1.1)
Collecting underthesea
  Obtaining dependency information for underthesea from https://files.pythonhosted.org/packages/c2/08/f8827734caf4fee1642bb08129afca92579633d8f72fbf0bc2f9a73aa69c/underthesea-6.7.0-py3-none-any.whl.metadata
  Downloading underthesea-6.7.0-py3-none-any.whl.metadata (14 kB)
Requirement already satisfied: Click>=6.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (8.1.7)
Requirement already satisfied: python-crfsuite>=0.9.6 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (0.9.9)
Requirement already satisfied: nltk in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (3.8.1)
Requirement already satisfied: tqdm in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (4.66.1)
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (2.31.0)
Requirement already satisfied: joblib in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (1.3.2)
Requirement already satisfied: scikit-learn in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (1.3.1)
Requirement already satisfied: PyYAML in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (6.0.1)
Requirement already satisfied: underthesea-core==1.0.4 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from underthesea) (1.0.4)
Requirement already satisfied: regex>=2021.8.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk->underthesea) (2023.8.8)
Requirement already satisfied: charset-normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests->underthesea) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests->underthesea) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests->underthesea) (2.0.5)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from requests->underthesea) (2023.7.22)
Requirement already satisfied: numpy<2.0,>=1.17.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn->underthesea) (1.26.0)
Requirement already satisfied: scipy>=1.5.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn->underthesea) (1.11.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from scikit-learn->underthesea) (3.2.0)
Downloading underthesea-6.7.0-py3-none-any.whl (20.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 20.9/20.9 MB 6.3 MB/s eta 0:00:00
Installing collected packages: underthesea
  Attempting uninstall: underthesea
    Found existing installation: underthesea 6.1.1
    Uninstalling underthesea-6.1.1:
      Successfully uninstalled underthesea-6.1.1
Successfully installed underthesea-6.7.0

BLKSerenes-Mac:underthesea_core-1.0.4 blkserene$ python3
Python 3.10.11 (v3.10.11:7d4cc5aa85, Apr  4 2023, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from underthesea import sentiment
>>> sentiment('hàng kém chất lg,chăn đắp lên dính lông lá khắp người. thất vọng')
'negative'