1 第三方库的安装及更新
待安装完成Python3.X和Python2.7后,菜鸟迫不及待准备上手Pycharm以便大展拳脚,然而各种第三方库无法直接成功安装,没办法,无奈选择老办法。
1.1 pip安装确认
# 路径确认
C:\Users\Administrator>cd E:\Python\Scripts
# pip安装情况确认
C:\Users\Administrator>pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to
WARNING, ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
(a)bort).
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the
certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output
1.2 第三方库安装
# 以Pillow安装为例
C:\Users\Administrator>pip install pillow
Collecting pillow
Downloading https://files.pythonhosted.org/packages/1b/50/869910cd7110157fbefd0fed3db3656c1951f1bceecdd00e3716aa269609/Pillow-5.2.0-cp36-cp36m-win_amd64.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 79kB/s
Installing collected packages: pillow
Successfully installed pillow-5.2.0
1.3 第三方库更新
由于在操作过程中,发现先前所用的pip版本过低,部分第三方库已经无法使用,于是对Pip进行了版本更新,其它第三方库的更新与之相同。
C:\Users\Administrator>python -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 100kB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.0
1.4 第三方库安装超时
国内下载部分第三方库时候会提示timeout,此时可采取pip install 需要安装的包 -i 链接地址 --trusted-host 域名
,此处给出一些国内镜像地址:
镜像源 | 链接地址 |
---|---|
阿里云 | http://mirrors.aliyun.com/pypi/simple |
豆瓣 | http://pypi.douban.com/simple |
清华大学 | https://pypi.tuna.tsinghua.edu.cn/simple |
中国科技大学 | https://pypi.mirrors.ustc.edu.cn/simple |
中国科学技术大学 | http://pypi.mirrors.ustc.edu.cn/simple |
华中理工大学 | http://pypi.hustunique.com/ |
山东理工大学 | http://pypi.sdutlinux.org/ |
# 以taichi安装为例
# 豆瓣镜像
C:\Users\Administrator>pip install taichi-nightly -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
# 阿里云镜像
C:\Users\Administrator>pip install taichi-nightly -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com