sys.path设置


Python导入模块时路径搜索有两种方式


1.从当前路径中搜索

2.从sys.path路径中搜索


我们可以把需要导入的模块路径添加到sys.path中,如此使用起来会比较方便


#临时添加,退出失效

>>>import sys

>>>sys.path.append('path_name')


#添加到环境变量,永久生效

vi .bash_profile 

export PYTHONPATH=path_name





你可能感兴趣的:(Python,sys.path)