Alpine に Python の reportlab を入れたら Not a directory: '/dev/null/.reportlab_mods' になる場合

Posted by: ytyng 3 months, 2 weeks ago
 File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/var/src/manga-server-django/delivery/models.py", line 464, in <module>
from reportlab.pdfbase import pdfmetrics
File "/usr/lib/python3.9/site-packages/reportlab/__init__.py", line 56, in <module>
_fake_import(os.path.expanduser(os.path.join('~','.reportlab_mods')),'reportlab_mods')
File "/usr/lib/python3.9/site-packages/reportlab/__init__.py", line 28, in _fake_import
sys.modules[name] = m.load_module(name)
File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 1034, in load_module
File "<frozen importlib._bootstrap_external>", line 859, in load_module
File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 851, in exec_module
File "<frozen importlib._bootstrap_external>", line 987, in get_code
File "<frozen importlib._bootstrap_external>", line 1044, in get_data
NotADirectoryError: [Errno 20] Not a directory: '/dev/null/.reportlab_mods'

というエラーが出た場合。

エラー文言をよく見ると、

os.path.join('~','.reportlab_mods')

 '/dev/null/.reportlab_mods'

になってエラーになってるので、

ENV HOME=/var/app

的なものを dockerfile に入れる。ディレクトリは権限のある適当なディレクトリ。

root 以外で python アプリを実行していると発生する。

Currently unrated

Comments

Archive

2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011