SamuraiT / mecab-python3

:snake: mecab-python. you can find original version here:http://taku910.github.io/mecab/
https://pypi.python.org/pypi/mecab-python3
Other
526 stars 51 forks source link

Trouble installing on Big Sur #69

Closed polm closed 3 years ago

polm commented 3 years ago

Originally by @EgnaroJQ From here:


I try this solution but it still failed initializing MeCab. I've update pip to version 21.1.3 and use the new version to install Mecab, unidic-lite, unidic and ipadic. It shows

arguments: 
[ifs] no such file or directory: /Users/MyName/opt/anaconda3/lib/python3.7/site-packages/unidic/dicdir/mecabrc

And when I try this line tagger = MeCab.Tagger('-r/dev/null -d/home/hoge/mydic') It shows

arguments: -r /dev/null -d /usr/local/lib/mecab/dic/mydic
[ifs] no such file or directory: /usr/local/lib/mecab/dic/mydic/dicrc

I work on a Mac with Big Sur and my python version is 3.7.9. I would appreciate any help you lend to me. Thanks in advance.

polm commented 3 years ago

If you uninstall unidic and ipadic does it work? After uninstalling them use MeCab.Tagger() with no arguments.

To clarify, did you install mecab-python3? Please note that mecab on PyPI is a separate library and not maintained by me.

If uninstalling unidic and ipadic works, the issue is that you didn't run the extra install step for UniDic.

If that doesn't solve your issue let me know.

EgnaroJQ commented 3 years ago

Thanks @polm for your immediate reply! To clarify, I did installed mecab-python3 version. I uninstalled mecab-python3 and all the dictionary libraries, and installed mecab-python3 and unidic-lite again with pip. Then I tried Mecab.Tagger(),but failed with this warning:

File "/Users/Myname/demo.py", line 2, in <module>
    wakati = MeCab.Tagger()
  File "/Users/Myname/opt/anaconda3/lib/python3.7/site-packages/MeCab/__init__.py", line 117, in __init__
    unidicdir = try_import_unidic()
  File "/Users/Myname/opt/anaconda3/lib/python3.7/site-packages/MeCab/__init__.py", line 62, in try_import_unidic
    return unidic.DICDIR
 AttributeError: module 'unidic' has no attribute 'DICDIR'

Thanks in advance!

polm commented 3 years ago

Thanks for the clarification.

With your current error, what's happening is that import unidic succeeds, but it doesn't have the DICDIR attribute. All versions of unidic-py have that attribute, so something weird is going on. Do you have a file named unidic.py in the same directory as demo.py by any chance? If so you should rename it.

If that doesn't work, can you share the output of pip freeze?

EgnaroJQ commented 3 years ago

Thanks @polm ! I checked the folder. There's no unidic-py or unidic.py in it. And the output of pip freezeis:

(base) Myname@MynameMacBook-Pro ~ % pip freeze
alabaster==0.7.12
anaconda-client==1.7.2
anaconda-navigator==1.9.12
anaconda-project @ file:///tmp/build/80754af9/anaconda-project_1610472525955/work
applaunchservices==0.2.1
appnope @ file:///opt/concourse/worker/volumes/live/4f734db2-9ca8-4d8b-5b29-6ca15b4b4772/volume/appnope_1606859466979/work
appscript @ file:///opt/concourse/worker/volumes/live/27fecc2e-9c75-4367-685d-08900606dee2/volume/appscript_1611427007141/work
argh==0.26.2
argon2-cffi @ file:///opt/concourse/worker/volumes/live/c4db8eed-7de0-4d68-400c-2ea7e21d3750/volume/argon2-cffi_1596828478065/work
asn1crypto @ file:///tmp/build/80754af9/asn1crypto_1596577642040/work
astroid @ file:///opt/concourse/worker/volumes/live/b22b518b-f584-4586-5ee9-55bfa4fca96e/volume/astroid_1592495912194/work
astropy @ file:///opt/concourse/worker/volumes/live/4d41c9c8-7ad9-470a-4924-a86cb5c771d4/volume/astropy_1606922930702/work
async-generator==1.10
atomicwrites==1.4.0
attrs @ file:///tmp/build/80754af9/attrs_1604765588209/work
autopep8 @ file:///tmp/build/80754af9/autopep8_1596578164842/work
Babel @ file:///tmp/build/80754af9/babel_1607110387436/work
backcall==0.2.0
backports.functools-lru-cache @ file:///tmp/build/80754af9/backports.functools_lru_cache_1605305165209/work
backports.shutil-get-terminal-size @ file:///tmp/build/80754af9/backports.shutil_get_terminal_size_1608222128777/work
backports.tempfile @ file:///home/linux1/recipes/ci/backports.tempfile_1610991236607/work
backports.weakref==1.0.post1
beautifulsoup4 @ file:///home/linux1/recipes/ci/beautifulsoup4_1610988766420/work
bitarray @ file:///opt/concourse/worker/volumes/live/489c9650-2944-4132-457f-21b0cf86f3a5/volume/bitarray_1611254394777/work
bkcharts==0.2
bleach @ file:///tmp/build/80754af9/bleach_1611690509631/work
bokeh @ file:///opt/concourse/worker/volumes/live/17495d14-5b57-4c12-6d6b-201edb177b9e/volume/bokeh_1603297848703/work
boto==2.49.0
Bottleneck==1.3.2
brotlipy==0.7.0
certifi==2021.5.30
cffi @ file:///opt/concourse/worker/volumes/live/2aa8abfe-8b8d-4889-78d9-837b74c3cd64/volume/cffi_1606255119410/work
chardet @ file:///opt/concourse/worker/volumes/live/9efbf151-b45b-463d-6340-a5c399bf00b7/volume/chardet_1607706825988/work
click @ file:///home/linux1/recipes/ci/click_1610990599742/work
click-config-file==0.6.0
click-plugins==1.1.1
cloudpickle @ file:///tmp/build/80754af9/cloudpickle_1598884132938/work
clyent==1.2.2
colorama @ file:///tmp/build/80754af9/colorama_1607707115595/work
conda==4.10.1
conda-build==3.18.9
conda-package-handling @ file:///opt/concourse/worker/volumes/live/41a2ba95-d84c-4c06-4d6e-5665866bc5b4/volume/conda-package-handling_1603018173200/work
conda-verify==3.4.2
configobj==5.0.6
contextlib2==0.6.0.post1
cryptography @ file:///opt/concourse/worker/volumes/live/41c3d62a-f1f8-46ce-414a-9adaf4ea7d96/volume/cryptography_1607636752064/work
cycler==0.10.0
Cython @ file:///opt/concourse/worker/volumes/live/0be2fe5e-2479-4ba4-6436-ec8985045960/volume/cython_1605457635746/work
cytoolz==0.11.0
dask @ file:///tmp/build/80754af9/dask-core_1611341281313/work
decorator==4.4.2
defusedxml==0.6.0
diff-match-patch @ file:///tmp/build/80754af9/diff-match-patch_1594828741838/work
distributed @ file:///opt/concourse/worker/volumes/live/b33b4b6f-691a-4390-599d-9ebf3899baf3/volume/distributed_1611341513290/work
docutils==0.16
easygui==0.98.1
emoji==1.2.0
entrypoints==0.3
et-xmlfile==1.0.1
fastcache==1.1.0
filelock @ file:///home/linux1/recipes/ci/filelock_1610993975404/work
flake8 @ file:///tmp/build/80754af9/flake8_1601911421857/work
Flask==1.1.2
fsspec @ file:///tmp/build/80754af9/fsspec_1602684995936/work
future==0.18.2
gevent @ file:///opt/concourse/worker/volumes/live/b0345029-1183-4fbd-7cde-0ac254af8299/volume/gevent_1610995751089/work
glob2 @ file:///home/linux1/recipes/ci/glob2_1610991677669/work
gmpy2==2.0.8
greenlet @ file:///opt/concourse/worker/volumes/live/0051114e-81b1-4a15-4054-b5a71cd53179/volume/greenlet_1600874059672/work
h5py==2.10.0
HeapDict==1.0.1
html5lib @ file:///tmp/build/80754af9/html5lib_1593446221756/work
idna @ file:///home/linux1/recipes/ci/idna_1610986105248/work
imagecodecs @ file:///opt/concourse/worker/volumes/live/3cc3abec-1f54-40c7-4384-7d75221c9972/volume/imagecodecs_1611258197831/work
imageio @ file:///tmp/build/80754af9/imageio_1594161405741/work
imagesize==1.2.0
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1602276842396/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
intervaltree @ file:///tmp/build/80754af9/intervaltree_1598376443606/work
ipykernel @ file:///opt/concourse/worker/volumes/live/73e8766c-12c3-4f76-62a6-3dea9a7da5b7/volume/ipykernel_1596206701501/work/dist/ipykernel-5.3.4-py3-none-any.whl
ipython @ file:///opt/concourse/worker/volumes/live/4f393720-ac1e-4c11-6939-afec7c0337aa/volume/ipython_1610725411441/work
ipython-genutils @ file:///tmp/build/80754af9/ipython_genutils_1606773439826/work
ipywidgets @ file:///tmp/build/80754af9/ipywidgets_1610481889018/work
isort @ file:///tmp/build/80754af9/isort_1602603989581/work
itsdangerous==1.1.0
jdcal==1.4.1
jedi==0.15.2
Jinja2 @ file:///home/linux1/recipes/ci/jinja2_1610990516718/work
joblib @ file:///tmp/build/80754af9/joblib_1607970656719/work
json5==0.9.5
jsonmerge==1.8.0
jsonpickle @ file:///tmp/build/80754af9/jsonpickle_1613502777040/work
jsonschema @ file:///tmp/build/80754af9/jsonschema_1602607155483/work
jupyter==1.0.0
jupyter-client @ file:///tmp/build/80754af9/jupyter_client_1601311786391/work
jupyter-console @ file:///tmp/build/80754af9/jupyter_console_1598884538475/work
jupyter-core @ file:///opt/concourse/worker/volumes/live/a00c6604-807b-490b-6c3f-c66a22f02fab/volume/jupyter_core_1606148990852/work
jupyterlab==2.2.6
jupyterlab-pygments @ file:///tmp/build/80754af9/jupyterlab_pygments_1601490720602/work
jupyterlab-server @ file:///tmp/build/80754af9/jupyterlab_server_1594164409481/work
jupyterlab-widgets @ file:///tmp/build/80754af9/jupyterlab_widgets_1609884341231/work
keyring @ file:///opt/concourse/worker/volumes/live/3740b050-01bf-4b4f-419e-73653efea565/volume/keyring_1611601956871/work
kiwisolver @ file:///opt/concourse/worker/volumes/live/7f2d375c-30f6-458e-63e3-3be3b4be2918/volume/kiwisolver_1604014611853/work
lazy-object-proxy @ file:///opt/concourse/worker/volumes/live/5927f8af-674c-485c-6607-a9c3a98dcf3a/volume/lazy-object-proxy_1607707356587/work
libarchive-c @ file:///home/linux1/recipes/ci/python-libarchive-c_1610974153025/work
llvmlite==0.34.0
locket==0.2.1
lxml @ file:///opt/concourse/worker/volumes/live/2f2e9d7c-80fe-4a43-633f-52750fdb2409/volume/lxml_1606516857523/work
MarkupSafe==1.1.1
matplotlib @ file:///opt/concourse/worker/volumes/live/61624fbb-2a49-420f-6e89-f3df5b5e7cab/volume/matplotlib-base_1603373809385/work
mccabe==0.6.1
mecab-python3==1.0.4
mistune==0.8.4
mkl-fft==1.2.0
mkl-random==1.1.1
mkl-service==2.3.0
mock @ file:///tmp/build/80754af9/mock_1607622725907/work
more-itertools==8.8.0
mpmath==1.1.0
msgpack @ file:///opt/concourse/worker/volumes/live/f823bc9b-1edb-4ee9-5d19-9de1ac61f3d9/volume/msgpack-python_1607965810722/work
multipledispatch==0.6.0
navigator-updater==0.2.1
nbclient @ file:///tmp/build/80754af9/nbclient_1602783176460/work
nbconvert @ file:///opt/concourse/worker/volumes/live/d4b0787b-b6c8-4d28-5453-3381885d5b33/volume/nbconvert_1601914848300/work
nbformat @ file:///tmp/build/80754af9/nbformat_1610738111109/work
nest-asyncio @ file:///tmp/build/80754af9/nest-asyncio_1606153767164/work
networkx @ file:///tmp/build/80754af9/networkx_1598376031484/work
nltk @ file:///tmp/build/80754af9/nltk_1592496090529/work
nose @ file:///tmp/build/80754af9/nose_1606773131901/work
notebook @ file:///opt/concourse/worker/volumes/live/918fd277-9373-4d2e-5e16-cbd1adfac363/volume/notebook_1611341013189/work
numba @ file:///opt/concourse/worker/volumes/live/a92243fb-d564-44ee-7f97-342ce782c8cc/volume/numba_1600108029490/work
numexpr @ file:///opt/concourse/worker/volumes/live/c18c3d5e-dc79-4b6b-6b23-59acb6850096/volume/numexpr_1609354654585/work
numpy @ file:///opt/concourse/worker/volumes/live/a1b5ea96-b05c-40ba-5dfb-4542ece1c186/volume/numpy_and_numpy_base_1603491228242/work
numpydoc @ file:///tmp/build/80754af9/numpydoc_1605117425582/work
oauthlib==3.1.1
olefile==0.46
openpyxl @ file:///tmp/build/80754af9/openpyxl_1610651698508/work
packaging @ file:///tmp/build/80754af9/packaging_1607971725249/work
pandas==1.2.5
pandocfilters @ file:///opt/concourse/worker/volumes/live/315ac9bb-93fd-4adc-6795-345692fcfaed/volume/pandocfilters_1605120446899/work
parso==0.5.2
partd==1.1.0
path @ file:///opt/concourse/worker/volumes/live/91b74300-26ac-452d-76ae-e6d781176bc4/volume/path_1607537225637/work
pathlib2 @ file:///opt/concourse/worker/volumes/live/8e57d73a-998f-4fa8-5295-7c064efc1e48/volume/pathlib2_1607024984248/work
pathtools==0.1.2
patsy==0.5.1
pep8==1.7.1
pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work
pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work
Pillow @ file:///opt/concourse/worker/volumes/live/0aff898a-aba9-4321-76c2-58d629e96356/volume/pillow_1617386155885/work
pkginfo==1.7.0
plac==1.3.3
pluggy==0.13.1
ply==3.11
prometheus-client @ file:///tmp/build/80754af9/prometheus_client_1606344362066/work
prompt-toolkit @ file:///tmp/build/80754af9/prompt-toolkit_1602688806899/work
psutil @ file:///opt/concourse/worker/volumes/live/abb7a219-3a4a-4ff9-4158-148060faae29/volume/psutil_1598370243710/work
ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
py @ file:///tmp/build/80754af9/py_1607971587848/work
pycodestyle==2.6.0
pycosat==0.6.3
pycparser @ file:///tmp/build/80754af9/pycparser_1594388511720/work
pycrypto==2.6.1
pycurl==7.43.0.6
pydocstyle @ file:///tmp/build/80754af9/pydocstyle_1598885001695/work
pyerfa @ file:///opt/concourse/worker/volumes/live/4777125d-48ad-4a74-575f-3dfd04546bfd/volume/pyerfa_1606860211879/work
pyflakes==2.2.0
Pygments @ file:///tmp/build/80754af9/pygments_1610565767015/work
pylint @ file:///opt/concourse/worker/volumes/live/9eebf2dc-3c74-4778-701c-c55b13929def/volume/pylint_1598624018844/work
pymlask==0.3.2
pyodbc===4.0.0-unsupported
pyOpenSSL @ file:///tmp/build/80754af9/pyopenssl_1608057966937/work
pyparsing @ file:///home/linux1/recipes/ci/pyparsing_1610983426697/work
pyrsistent @ file:///opt/concourse/worker/volumes/live/656e0c1b-ef87-4251-4a51-1290b2351993/volume/pyrsistent_1600141745371/work
PySocks @ file:///opt/concourse/worker/volumes/live/ef943889-94fc-4539-798d-461c60b77804/volume/pysocks_1605305801690/work
pytest==0.0.0
python-dateutil==2.8.1
python-jsonrpc-server==0.3.4
python-language-server==0.31.9
pytz @ file:///tmp/build/80754af9/pytz_1608922264688/work
PyWavelets @ file:///opt/concourse/worker/volumes/live/4c8a2af4-1e43-4df6-4c7a-c73342176802/volume/pywavelets_1601658329224/work
PyYAML==5.4.1
pyzmq==20.0.0
QDarkStyle==2.8.1
QtAwesome @ file:///tmp/build/80754af9/qtawesome_1602272867890/work
qtconsole @ file:///tmp/build/80754af9/qtconsole_1600870028330/work
QtPy==1.9.0
regex @ file:///opt/concourse/worker/volumes/live/75a20732-2306-4d51-79ce-516009aca709/volume/regex_1606773011423/work
requests @ file:///tmp/build/80754af9/requests_1608241421344/work
requests-oauthlib==1.3.0
rope @ file:///tmp/build/80754af9/rope_1602264064449/work
Rtree==0.9.4
ruamel-yaml==0.15.87
scikit-image==0.17.2
scikit-learn @ file:///opt/concourse/worker/volumes/live/2dacdc11-21e7-44f5-57b4-6b8eb6ceb626/volume/scikit-learn_1598376924598/work
scipy @ file:///opt/concourse/worker/volumes/live/9698578f-91da-4d5f-6fce-b26b1f42eb5a/volume/scipy_1597686637948/work
seaborn @ file:///tmp/build/80754af9/seaborn_1608578541026/work
searchtweets-v2==1.0.7
Send2Trash @ file:///tmp/build/80754af9/send2trash_1607525499227/work
simplegeneric==0.8.1
singledispatch @ file:///tmp/build/80754af9/singledispatch_1602523705405/work
six @ file:///opt/concourse/worker/volumes/live/f983ba11-c9fe-4dff-7ce7-d89b95b09771/volume/six_1605205318156/work
snowballstemmer @ file:///tmp/build/80754af9/snowballstemmer_1611258885636/work
sortedcollections @ file:///tmp/build/80754af9/sortedcollections_1611172717284/work
sortedcontainers @ file:///tmp/build/80754af9/sortedcontainers_1606865132123/work
soupsieve @ file:///tmp/build/80754af9/soupsieve_1607965878077/work
Sphinx @ file:///tmp/build/80754af9/sphinx_1610133430332/work
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
sphinxcontrib-websupport @ file:///tmp/build/80754af9/sphinxcontrib-websupport_1597081412696/work
spyder==4.1.2
spyder-kernels @ file:///opt/concourse/worker/volumes/live/e7caf393-58c4-4966-7562-d6cfd6d2cb12/volume/spyder-kernels_1599056818432/work
SQLAlchemy @ file:///opt/concourse/worker/volumes/live/a37d3150-f8e8-4e5d-4ec2-01f3154ae8e6/volume/sqlalchemy_1608243746150/work
statsmodels @ file:///opt/concourse/worker/volumes/live/c88b3fa8-c6a0-4ff4-6b2f-464912022a9d/volume/statsmodels_1606925355294/work
sympy @ file:///opt/concourse/worker/volumes/live/347e855c-d365-447b-5b46-aa042092978f/volume/sympy_1608137682049/work
tables==3.6.1
tblib @ file:///tmp/build/80754af9/tblib_1597928476713/work
terminado==0.9.2
testpath==0.4.4
threadpoolctl @ file:///tmp/tmp9twdgx9k/threadpoolctl-2.1.0-py3-none-any.whl
tifffile @ file:///tmp/build/80754af9/tifffile_1610739638720/work
toml @ file:///tmp/build/80754af9/toml_1592853716807/work
toolz @ file:///home/linux1/recipes/ci/toolz_1610987900194/work
tornado @ file:///opt/concourse/worker/volumes/live/d531d395-893c-4ca1-6a5f-717b318eb08c/volume/tornado_1606942307627/work
tqdm==4.61.1
traitlets @ file:///tmp/build/80754af9/traitlets_1602787416690/work
twarc==2.3.1
twarc-csv==0.3.5
typed-ast @ file:///opt/concourse/worker/volumes/live/f24de662-b4e3-467b-58a8-199787662676/volume/typed-ast_1610484563580/work
typing-extensions @ file:///tmp/build/80754af9/typing_extensions_1598376058250/work
ujson==1.35
unicodecsv==0.14.1
unidic-lite==1.0.8
urllib3 @ file:///tmp/build/80754af9/urllib3_1611694770489/work
wasabi==0.8.2
watchdog @ file:///opt/concourse/worker/volumes/live/5093631c-7a07-4a9a-7f4a-e1547c3d779d/volume/watchdog_1606939121159/work
wcwidth @ file:///tmp/build/80754af9/wcwidth_1593447189090/work
webencodings==0.5.1
Werkzeug==1.0.1
widgetsnbextension==3.5.1
wrapt @ file:///opt/concourse/worker/volumes/live/0fc82c5d-8835-44d1-5d35-827091fc1c53/volume/wrapt_1607712501273/work
wurlitzer @ file:///opt/concourse/worker/volumes/live/59acb45c-07e7-4304-57af-e84f3889d3ef/volume/wurlitzer_1594753863419/work
xlrd @ file:///tmp/build/80754af9/xlrd_1608072521494/work
XlsxWriter @ file:///tmp/build/80754af9/xlsxwriter_1602692860603/work
xlwings==0.21.4
xlwt==1.3.0
xmltodict==0.12.0
yapf @ file:///tmp/build/80754af9/yapf_1593528177422/work
zict==2.0.0
zipp @ file:///tmp/build/80754af9/zipp_1604001098328/work
zope.event==4.5.0
zope.interface @ file:///opt/concourse/worker/volumes/live/9b4a6693-5968-464b-4257-b8041d527125/volume/zope.interface_1606940322645/work

Looking forward to your reply🙏

polm commented 3 years ago

OK, that's weird. Does this work?

import MeCab
import unidic_lite
tagger = MeCab.Tagger(f"-r/dev/null -d {unidic_lite.DICDIR}")
print(tagger("テストです"))

If that doesn't work it might help to know the output of the below code, including any errors:

import unidic
print(unidic.__file__)
print(unidic.DICDIR)
EgnaroJQ commented 3 years ago

Thanks @polm for your patience!

import MeCab
import unidic_lite
tagger = MeCab.Tagger(f"-r/dev/null -d {unidic_lite.DICDIR}")
print(tagger("テストです"))

↑It doesn't work and still shows:

 File "/Users/Myname/code_climate/demo.py", line 3, in <module>
    tagger = MeCab.Tagger(f"-r/dev/null -d {unidic_lite.DICDIR}")
  File "/Users/Myname/opt/anaconda3/lib/python3.7/site-packages/MeCab/__init__.py", line 117, in __init__
    unidicdir = try_import_unidic()
  File "/Users/Myname/opt/anaconda3/lib/python3.7/site-packages/MeCab/__init__.py", line 62, in try_import_unidic
    return unidic.DICDIR
AttributeError: module 'unidic' has no attribute 'DICDIR'

And with

import unidic
print(unidic.__file__)
print(unidic.DICDIR)

it shows:

(base) Myname@MynameMacBook-Pro ~ % /Users/wangjingqi/opt/anaconda3/bin/python /Users/Myname/code_climate/demo.py
None
Traceback (most recent call last):
  File "/Users/Myname/code_climate/demo.py", line 3, in <module>
    print(unidic.DICDIR)
AttributeError: module 'unidic' has no attribute 'DICDIR'

I tried restarting my Macbook and reinstalling macab-python3 and unidic-lite again and it failed again. It's really weird.

polm commented 3 years ago

OK, it looks like there is something called unidic in your Python PATH somewhere.

Try this: run python -v from the command line. There will be a lot of output and then there will be a prompt. If you type import unidic it should tell you where that's being loaded from. Can you paste the output of the prompt after running import unidic?

polm commented 3 years ago

Actually, instead of python -v you should be able to just share the output of this:

import inspect
import unidic
print(inspect.getfile(unidic))
EgnaroJQ commented 3 years ago

OK, it looks like there is something called unidic in your Python PATH somewhere.

Try this: run python -v from the command line. There will be a lot of output and then there will be a prompt. If you type import unidic it should tell you where that's being loaded from. Can you paste the output of the prompt after running import unidic?

I tried this and it showed:

>>> import unidic
# possible namespace for /Users/Myname/opt/anaconda3/lib/python3.7/site-packages/unidic
import 'unidic' # <_frozen_importlib_external._NamespaceLoader object at 0x7fdd64b460d0>

Actually, instead of python -v you should be able to just share the output of this:

import inspect
import unidic
print(inspect.getfile(unidic))

With this, it showed:

Traceback (most recent call last):
  File "/Users/Myname/code_climate/demo.py", line 3, in <module>
    print(inspect.getfile(unidic))
  File "/Users/Myname/opt/anaconda3/lib/python3.7/inspect.py", line 647, in getfile
    raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module 'unidic' (namespace)> is a built-in module

Is there anything to do with the Anaconda? Should I delete the unidic folder (it's empty) and try again?

polm commented 3 years ago

Yes, please delete the folder. I suspect you can remove it with conda uninstall unidic but I don't use conda so I'm not entirely sure.

EgnaroJQ commented 3 years ago

I deleted the folder and it works!!! (But I can't figure out what caused this problem.) Many thanks for your patient instruction!

polm commented 3 years ago

Glad that sorted it out! It is really weird that that folder existed. I guess your install of the unidic package got messed up somehow.

If you have any other questions please feel free to open a new issue.