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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章