之前安裝pip和ipython的過程很順利,從未出錯,但是...

自從重灌了win10的系統以後,安裝pip和ipython就各種出錯,可以說安裝之路很坎坷...

下面說一下我遇到的問題和安裝的方法:

因為我安裝的python是2.7的


在用pip安裝ipython的時候,

>pip install ipython

一直提示read time out苦大仇深的我就被逼無奈自行百度,研究之後發現換個國內的映象源就好了。

在命令列輸入

>echo %APPDATA%
得到%APPDATA%的路徑為
C:\Users\XXX\AppData\Roaming

但是在AppData\Roaming裡並沒有pip資料夾,於是就在AppData\Roaming建一個pip資料夾,在pip資料夾裡再建一個pip.ini檔案,然後把下面的加到這個檔案裡就可以了。

[global]
index-url = http://pypi.douban.com/simple

配好之後輸入下面的命令:

>pip install <包名> --trusted-host pypi.douban.com

下載安裝包就會特別的快啦!

列幾個國內的映象源:

阿里雲 速度最快 http://mirrors.aliyun.com/pypi/simple/ 
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple/
Python官方 https://pypi.python.org/simple/
v2ex http://pypi.v2ex.com/simple/
中國科學院 http://pypi.mirrors.opencas.cn/simple/
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/

pip在安裝python的時候就已經裝好了,但是當時python裝的是2.0版本的,在安裝ipython的時候就提示讓我更新pip到9.0。

根據提示

>python -m pip install --upgrade pip

更新pip還是一樣的結果...

>python -m pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages
You are using pip version 8.1.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

因為前面配好了源,所以可以直接用

>pip install --upgrade pip --trusted-host pypi.douban.com

就可以成功升級了。

pip升級的問題解決了,是時候解決ipython安裝的問題了...

C:\Users\CYCLE>pip install ipython
Collecting ipython
  The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.
  Could not find a version that satisfies the requirement ipython (from versions: )
No matching distribution found for ipython

C:\Users\CYCLE>pip install ipython --trusted-host pypi.douban.com
Collecting ipython
  Downloading http://pypi.doubanio.com/packages/4f/a7/fc647e9ce711cd630873c37219c0bd4438b8171211d813c7e6b316811e02/ipython-6.3.1.tar.gz (5.1MB)
    100% |████████████████████████████████| 5.1MB 3.3MB/s
    Complete output from command python setup.py egg_info:

    IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
    When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
    Beginning with IPython 6.0, Python 3.3 and above is required.

    See IPython `README.rst` file for more information:

        https://github.com/ipython/ipython/blob/master/README.rst

    Python sys.version_info(major=2, minor=7, micro=14, releaselevel='final', serial=0) detected.



    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\cycle\appdata\local\temp\pip-build-ctezzm\ipython\

提示說ipython 6.0+不支援python 2.6,2.7,3.0,3.1 ,3.2。我用的是python 2.7版本的,所以要安裝對應的ipython 5.x版本..於是

>pip install ipython==5.6 --trusted-host pypi.douban.com

安裝不同版本的ipython的時候要在ipython後面加版本號!!!例如:

>pip install ipython==版本號 --trusted-host 映象源

提示

Successfully installed backports.shutil-get-terminal-size-1.0.0 colorama-0.3.9 decorator-4.2.1 enum34-1.1.6 ipython-5.6.0 ipython-genutils-0.2.0 pathlib2-2.3.0 pickleshare-0.7.4 prompt-toolkit-1.0.15 pygments-2.2.0 scandir-1.7 simplegeneric-0.8.1 six-1.11.0 traitlets-4.3.2 wcwidth-0.1.7 win-unicode-console-0.5

就安裝成功了!!!


ipython的官方文件:http://ipython.readthedocs.io/en/stable/install/index.html
.