Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: gen_zip_code_seed.py #391

Closed
ghost opened this issue Oct 19, 2016 · 1 comment
Closed

ImportError: gen_zip_code_seed.py #391

ghost opened this issue Oct 19, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 19, 2016

Mozc-2.18.2620.102+24.0.oss

$ cd mozc-2.18.2620.102/src/dictionary/
$ python2 gen_zip_code_seed.py --zip_code=KEN_ALL.CSV --jigyosyo=JIGYOSYO.CSV >> test
Traceback (most recent call last):
  File "gen_zip_code_seed.py", line 59, in <module>
    from dictionary import zip_code_util
ImportError: No module named dictionary

This will fix it.

sed -i "s/from dictionary import zip_code_util/import zip_code_util/g" gen_zip_code_seed.py
@yukawa
Copy link
Collaborator

yukawa commented Oct 26, 2016

Thank you for the report and sorry about the trouble. This is actually a known issue regarding how Mozc team open-sources code from internal repository to GitHub. In internal repository, we assume that PYTHONPATH always includes the top directory of Mozc's source directory. Although we can forget about this when building Mozc because build_mozc.py automatically does this [1] for you, we have to do that manually when we manually run our Python scripts from console.

Can you try the following command instead?

cd mozc-2.18.2620.102/src
PYTHONPATH="${PYTHONPATH}:${PWD}" python dictionary/gen_zip_code_seed.py --zip_code=KEN_ALL.CSV --jigyosyo=JIGYOSYO.CSV >> test

We will update the comment in src/data/dictionary_oss/README.txt in a later commit to make it clear that we have to manually set PYTHONPATH.

[1]: src/build_mozc.py automatically updates PYTHONPATH as follows:

  # Add the mozc root directory to PYTHONPATH.
  original_python_path = os.environ.get('PYTHONPATH', '')
  depot_path = MOZC_ROOT
  python_path = os.pathsep.join([original_python_path, depot_path])
  os.environ['PYTHONPATH'] = python_path

@yukawa yukawa closed this as completed Oct 26, 2016
yukawa added a commit that referenced this issue Nov 20, 2016
With f130f24, it's now more obvious
that we have to specify PYTHONPATH when calling our python script
directly.

BUG=#391
TEST=
REF_BUG=32281113
REF_CL=137020326
REF_TIME=2016-10-24T06:05:10-07:00
REF_TIME_RAW=1477314310 -0700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant