0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Introduction

SudachiとかMecabとかで使う辞書を指定するときに、毎回ライブラリのパスコマンドで調べてとってくるの面倒すぎない…?
と思ったのでそもそもパス指定なんてライブラリの場所さえわかればコードで完結するよねと言うお話。
ライブラリのパスを何らかの理由で指定しなきゃいけないときに便利。

結論

get_libraryPath.py
import sudachipy

sudachipy.__path__
# ['/Users/(省略)/lib/python3.11/site-packages/sudachipy']
# pathだけ欲しい時は、sudachipy.__path__[0]

sudachipy.__name__
# /Users/(省略)/lib/python3.11/site-packages/sudachipy/__init__.py

多分任意のライブラリでできるが、osとかcsvとかはos.pyとかだったみたいで、__path__だと取れなかった。標準で入れてるやつがダメなのかと思ったけどtkinterは取れたので基準が不明。ディレクトリだと取れるんかな?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?