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?

More than 3 years have passed since last update.

Pythonのインポートディレクトリの順番(anaconda上)

Last updated at Posted at 2020-06-02

#Pythonのインポート順

EC2(amazonlinux2)上にanacondaを入れています。
環境にもよるみたいですがインポート順は下記。

(base) [ec2-user@ip-172-31-42-102 wk]$ echo $PYTHONPATH
/home/ec2-user/wk/lib
(base) [ec2-user@ip-172-31-42-102 wk]$ pwd
/home/ec2-user/wk
(base) [ec2-user@ip-172-31-42-102 wk]$ ls
path.py lib
(base) [ec2-user@ip-172-31-42-102 wk]$ cd ../
(base) [ec2-user@ip-172-31-42-102 ~]$ pwd
/home/ec2-user
(base) [ec2-user@ip-172-31-42-102 ~]$ python3 ./wk/path.py
['/home/ec2-user/wk',
 '/home/ec2-user/wk/lib',
 '/home/ec2-user',
 '/home/ec2-user/anaconda3/lib/python37.zip',
 '/home/ec2-user/anaconda3/lib/python3.7',
 '/home/ec2-user/anaconda3/lib/python3.7/lib-dynload',
 '/home/ec2-user/anaconda3/lib/python3.7/site-packages']		

①pyファイルがあるディレクトリ
②PYTHONPATHに設定しているディレクトリ
③カレントディレクトリ
④anacondaの標準、サードパーティディレクトリ

下記でインポート順を調べれるため、気になったときは試してみる。

path.py
import sys
import pprint

pprint.pprint(sys.path)
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?