1

We recently installed pykakasi package from Git on Linux server on BigData Cluster.

After installation I tried the test program from "Readme" and received this error.

Error Received:

PermissionError: [Errno 13] Permission denied: '/opt/python/python35/lib/python3.5/site-packages/pykakasi/kanwadict3.db/data'

I tried to research all the issues reported on Git. Also, searched this and other forums for possible solution but nothing worked.

Program I was testing:

import pykakasi

text = u"かな漢字交じり文"
kakasi = pykakasi.kakasi()
kakasi.setMode("H","a") # Hiragana to ascii, default: no conversion
kakasi.setMode("K","a") # Katakana to ascii, default: no conversion
kakasi.setMode("J","a") # Japanese to ascii, default: no conversion
kakasi.setMode("r","Hepburn") # default: use Hepburn Roman table
kakasi.setMode("s", True) # add space, default: no separator
kakasi.setMode("C", True) # capitalize, default: no capitalize
conv = kakasi.getConverter()
result = conv.do(text)
print(result)

Expected Output: kana Kanji Majiri Bun

Detailed Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/python/python35/lib/python3.5/site-packages/pykakasi/kakasi.py", line 99, in getConverter
    self._conv["J"] = J2(self._mode["J"], method=self._option["r"])
  File "/opt/python/python35/lib/python3.5/site-packages/pykakasi/j2.py", line 48, in __init__
    self._kanwa = kanwa()
  File "/opt/python/python35/lib/python3.5/site-packages/pykakasi/kanwa.py", line 32, in __init__
    self._kanwadict = dbm.open(dictpath, 'r')
  File "/opt/python/python35/lib/python3.5/site-packages/semidbm/db.py", line 355, in open
    return _SemiDBMReadOnly(filename, **kwargs)
  File "/opt/python/python35/lib/python3.5/site-packages/semidbm/db.py", line 40, in __init__
    self._load_db()
  File "/opt/python/python35/lib/python3.5/site-packages/semidbm/db.py", line 49, in _load_db
    self._data_fd = os.open(self._data_filename, compat.DATA_OPEN_FLAGS)
PermissionError: [Errno 13] Permission denied: '/opt/python/python35/lib/python3.5/site-packages/pykakasi/kanwadict3.db/data'
buræquete
  • 14,226
  • 4
  • 44
  • 89
Sam S
  • 39
  • 4
  • It works in my local `kana Kanji Majiri Bun` is printed out, something is wrong with your installation location of the `pykakasi` package, and the folder access permission seems to be the problem... Can you check the permissions of the said folder & the file? – buræquete Jun 20 '19 at 03:37
  • Thank you for quick response...I can't change any folder permissions as it needs root access – Sam S Jun 20 '19 at 03:38
  • You can try to first install the `pykakasi` in a folder that has your permission, check [this](https://stackoverflow.com/questions/2915471/install-a-python-package-into-a-different-directory-using-pip) then try to import it within your script via [import from path](https://stackoverflow.com/questions/4383571/importing-files-from-different-folder) otherwise you'd need to run the script as root I think... – buræquete Jun 20 '19 at 03:42
  • Did my answer help you to resolve the trouble? If so please accept it, or let me know if I can help any further! – buræquete Aug 02 '19 at 09:54

1 Answers1

0

I had the similar issue before, what I had done was that getting the imported packages in my local, e.g.

  • ~/myLocal/code.py
  • ~/myLocal/package/... -> contains the package that is used in code.

To do that, you can use something from here to install the desired package in a custom path. Or find some other way to achieve this. In the end you can just refer to this package with path as detailed here

Something like;

# code.py
import package.targetPackage as targetPackage
...
buræquete
  • 14,226
  • 4
  • 44
  • 89