Windows環境下更新pip和安裝ipython

之前安裝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
<span>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.</span>

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

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

就可以成功升級了。

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

C:\Users\CYCLE>pip install ipython
<span>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
</span>
C:\Users\CYCLE>pip install ipython --trusted-host pypi.douban.com
<span>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 <span class="hljs-number">6.0</span>+ does not support Python <span class="hljs-number">2.6</span>, <span class="hljs-number">2.7</span>, <span class="hljs-number">3.0</span>, <span class="hljs-number">3.1</span>, or <span class="hljs-number">3.2</span>.
When using Python <span class="hljs-number">2.7</span>, please install IPython <span class="hljs-number">5.</span>x LTS <span class="hljs-built_in">Long</span> Term Support version.
Beginning with IPython <span class="hljs-number">6.0</span>, Python <span class="hljs-number">3.3</span> and above <span class="hljs-keyword">is</span> required.

See IPython `README.rst` file <span class="hljs-keyword">for</span> more information:

    https:<span class="hljs-comment">//github.com/ipython/ipython/blob/master/README.rst</span>

Python sys.version_info(major=<span class="hljs-number">2</span>, minor=<span class="hljs-number">7</span>, micro=<span class="hljs-number">14</span>, releaselevel=<span class="hljs-string">'final'</span>, serial=<span class="hljs-number">0</span>) detected.



----------------------------------------

Command “python setup.py egg_info” failed with error code 1 in c:\users\cycle\appdata\local\temp\pip-build-ctezzm\ipython&lt;/span>

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

>pip install ipython5.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



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