neocl / jamdict

Python 3 library for manipulating Jim Breen's JMdict, KanjiDic2, JMnedict and kanji-radical mappings
MIT License
130 stars 12 forks source link

Can't buid database file since latest release #40

Closed crisalis2 closed 3 years ago

crisalis2 commented 3 years ago

I can't build the database since the latest (I think) release. Before I just did python3 -m jamdict.tools import and it worked.  

Now python3 -m jamdict.tools import or python3 -m jamdict import give me this:

Traceback (most recent call last): File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/data/data/com.termux/files/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/jamdict/__main__.py", line 2, in <module> tools.main() File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/jamdict/tools.py", line 295, in main app.run() File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/chirptext/cli.py", line 135, in run args.func(self, args) File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/jamdict/tools.py", line 70, in import_data db_loc = os.path.abspath(os.path.expanduser(args.jdb)) File "/data/data/com.termux/files/usr/lib/python3.9/posixpath.py", line 231, in expanduser path = os.fspath(path) TypeError: expected str, bytes or os.PathLike object, not NoneType  

Everything seems fine in python3 -m jamdict info:

Jamdict 0.1a11.post1 Python library for using Japanese dictionaries and resources (Jim Breen's JMdict, KanjiDic2, KRADFILE, JMnedict)

Basic configuration ------------------------------------------------------------ JAMDICT_HOME: /data/data/com.termux/files/home/.jamdict [OK] jamdict-data: Not installed Config file : /data/data/com.termux/files/home/.jamdict/config.json

Data files ------------------------------------------------------------ Jamdict DB location: /storage/emulated/0/Documents/Dictionaries/jamdict.db - [OK] JMDict XML file : /storage/emulated/0/Documents/Dictionaries/JMdict_e.gz - [OK] KanjiDic2 XML file : /storage/emulated/0/Documents/Dictionaries/kanjidic2.xml.gz - [OK] JMnedict XML file : /storage/emulated/0/Documents/Dictionaries/JMnedict.xml.gz - [OK]

Jamdict database metadata ------------------------------------------------------------ jmdict.version: 1.08 jmdict.url: http://www.csse.monash.edu.au/~jwb/edict.html generator: jamdict generator_version: 0.1a9 generator_url: https://github.com/neocl/jamdict jmnedict.version: 1.08 jmnedict.url: https://www.edrdg.org/enamdict/enamdict_doc.html jmnedict.date: 2020-05-29 kanjidic2.version: 1.6 kanjidic2.url: https://www.edrdg.org/wiki/index.php/KANJIDIC_Project kanjidic2.date: April 2008

Others ------------------------------------------------------------ puchikarui: version 0.2a2 chirptext : version 0.1.2 lxml : True  

My config.json looks like this: { "JAMDICT_HOME": "/data/data/com.termux/files/home/.jamdict", "JAMDICT_DATA": "{JAMDICT_HOME}/data", "JAMDICT_DB": "/storage/emulated/0/Documents/Dictionaries/jamdict.db", "JMDICT_XML": "/storage/emulated/0/Documents/Dictionaries/JMdict_e.gz", "JMNEDICT_XML": "/storage/emulated/0/Documents/Dictionaries/JMnedict.xml.gz", "KD2_XML": "/storage/emulated/0/Documents/Dictionaries/kanjidic2.xml.gz", "KRADFILE": "/storage/emulated/0/Documents/Dictionaries/kradfile-u.gz" }  

This is Termux on Android, if that matters. Also I can't install jamdict-data from pip, it fails and asks me to install wheel, which doesn't solve the problem -- but that's another matter.

letuananh commented 3 years ago

Thank you for reporting this. It seems to be a serious bug. I'll investigate this asap.

letuananh commented 3 years ago

Hi @crisalis2 I have fixed the import tools in the patch 0.1a11.post2. Thanks again for spotting this bug. Can you help me to test it on your side to see if it works for you?

Also out of interest I installed Termux on my phone just now to see why jamdict-data didn't work. It seems that Termux Python releases don't include wheel by default like other Python distributions (pip list showed only pip 21.1.1 and setuptools 56.0.0 on my phone)

So I ran pip install wheel to install it and after that pip install jamdict jamdict-data worked as expected. I hope this helps :)

crisalis2 commented 3 years ago

I confirm that building the database works now and installing jamdict-data from pip works too. Thank you!