2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

<python>モジュールの場所

Posted at

#モジュールはどこにある?

モジュールなどをを使いたい時、私たちはこうするだろう。
import (モジュール名、またはファイル名)

しかし、pythonはどのようにしてこれを探すのか、つまり、モジュールなどの場所はどこか。

pythonを用いて、以下のようにそれらの場所を探すことができる。
import sys
for place in sys.path:
print(place)

#結果
これのどれか。カレントディレクトリ→深いディレクトリの順で、pythonは探してくれるようだ

/Users/Ryusei
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/bin
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python36.zip
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
/usr/local/lib/python3.6/site-packages```
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?