一、how does Python know where to find packages when you call import?
- use sys.path
二、How sys.path gets populated
As the docs explain, sys.path
is populated using the current working directory, followed by directories listed in your PYTHONPATH
environment variable, followed by installation-dependent default paths, which are controlled by the site
module.
三、pip国内镜像源配置
手动指定:pip -i http://pypi.douban.com/simple install dnspython
或者创建$HOME/.pip/pip.conf修改pip配置
[global]
trusted-host = mirrors.ustc.edu.cn
index-url = https://mirrors.ustc.edu.cn/pypi/web/simple
四、修改pip安装路径
手动指定:pip -t HOME/.pip/pip.conf修改pip配置 install sixHOME/.pip/pip.conf修改pip配置
target=$HOME/.pip/pip.conf修改pip配置