由于缺少权限,Python脚本无法访问导入的软件包文件

时间:2019-06-20 03:30:48

标签: python-3.x unix file-permissions

我们最近在BigData Cluster的Linux服务器上从Git安装了pykakasi软件包。

安装后,我尝试使用“自述文件”中的测试程序,并收到此错误。

收到错误:

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

我试图研究Git上报告的所有问题。另外,在此论坛和其他论坛中搜索了可能的解决方案,但没有任何效果。

我正在测试的程序:

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)

预期输出:kana Kanji Majiri Bun

详细错误:

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'

1 个答案:

答案 0 :(得分:0)

我以前也遇到过类似的问题,我所做的就是在本地获取导入的软件包,例如

  • /dev/dsk/c1t0d0s3 --swap -no -
  • ~/myLocal/code.py->包含代码中使用的软件包。

为此,您可以使用here中的内容在自定义路径中安装所需的软件包。或找到其他方法来实现这一目标。最后,您可以仅使用详细说明here

的路径来引用此软件包。

类似的东西

~/myLocal/package/...