python踩坑日记

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值