python包安裝-centos7/windows


 

 

1、修改pip源

臨時使用: 
可以在使用pip的時候在后面加上-i參數,指定pip源 
eg: pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

常用的源有:

 新版ubuntu要求使用https源,要注意。

# 清華源
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

# 阿里雲源
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

## 以下設置trusted-host也類似
# 中國科技大學 
https://pypi.mirrors.ustc.edu.cn/simple/
# 華中理工大學:
http://pypi.hustunique.com/
# 山東理工大學:
http://pypi.sdutlinux.org/ 
# 豆瓣:
http://pypi.douban.com/simple/

 

永久修改: 

linux: 
修改 ~/.pip/pip.conf (沒有就創建一個), 內容如下(以清華源為例)

[global]
index-url =  https://pypi.tuna.tsinghua.edu.cn/simple 
[install]
trusted-host= pypi.tuna.tsinghua.edu.cn

windows: 

(1)在windows文件管理器中,輸入 %APPDATA%

(2)在該目錄下新建pip文件夾,然后到pip文件夾里面去新建個pip.ini文件

(3)在新建的pip.ini文件中輸入以下內容(以阿里雲源為例):

 

阿里雲的源:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

 

離線下載網站:https://pypi.python.org/pypi(centos,windows),https://www.lfd.uci.edu/~gohlke/pythonlibs(windows)

 

six:pip install six

離線版:six-1.11.0-py2.py3-none-any.whl(centos版),six-1.11.0-py2.py3-none-any.whl(windows版),后面類似

pytz:pip install pytz

離線版:pytz-2017.3-py2.py3-none-any.whl,pytz-2017.3-py2.py3-none-any.whl

pillow:pip install pillow(自動安裝olefile, pillow)

離線版:Pillow-4.3.0-cp27-cp27mu-manylinux1_x86_64.whl,Pillow-4.3.0-cp27-cp27m-win_amd64.whl

numpy:pip install numpy

離線版:numpy-1.13.3-cp27-cp27mu-manylinux1_x86_64.whl,numpy-1.13.3-cp27-none-win_amd64.whl

decorator:pip install decorator

離線版:decorator-4.1.2-py2.py3-none-any.whl,decorator-4.1.2-py2.py3-none-any.whl

pyparsing:pip install pyparsing

離線版:pyparsing-2.2.0-py2.py3-none-any.whl,pyparsing-2.2.0-py2.py3-none-any.whl

scikit-learn:pip install scikit-learn

離線版:scikit_learn-0.19.1-cp27-cp27mu-manylinux1_x86_64.whl,scikit_learn-0.19.1-cp27-cp27m-win_amd64.whl

backports.functools-lru-cache:pip install backports.functools-lru-cache

離線版:backports.functools_lru_cache-1.4-py2.py3-none-any.whl,backports.functools_lru_cache-1.4-py2.py3-none-any.whl

cycler:pip install cycler(自動安裝six,cycler)

離線版:cycler-0.10.0-py2.py3-none-any.whl,cycler-0.10.0-py2.py3-none-any.whl

python-dateutilpip install python_dateutil(自動安裝six,python_dateutil)

離線版:python_dateutil-2.6.1-py2.py3-none-any.whl,python_dateutil-2.6.1-py2.py3-none-any.whl

scipy:pip install scipy(自動安裝numpy, scipy)

離線版:scipy-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl,scipy-1.0.0-cp27-none-win_amd64.whl

PyWavelets:pip install PyWavelets(自動安裝numpy,PyWavelets)

離線版:PyWavelets-0.5.2-cp27-cp27mu-manylinux1_x86_64.whl,PyWavelets-0.5.2-cp27-none-win_amd64.whl

pandas:pip install pandas(自動安裝six, python-dateutil, numpy, pytz, pandas

離線版:pandas-0.21.0-cp27-cp27mu-manylinux1_x86_64.whl,pandas-0.21.0-cp27-cp27m-win_amd64.whl

matplotlib:pip install matplotlib(自動安裝pyparsing, backports.functools-lru-cache, six, python-dateutil, subprocess32, pytz, cycler, numpy, matplotlib)

離線版:matplotlib-2.1.0-cp27-cp27mu-manylinux1_x86_64.whl,matplotlib-2.1.0-cp27-cp27m-win_amd64.whl

skimage:pip install scikit-image(自動安裝numpy, PyWavelets, scipy, decorator, networkx, six, pyparsing, backports.functools-lru-cache, python-dateutil, subprocess32, pytz, cycler, matplotlib, olefile, pillow, scikit-image)

離線版:scikit_image-0.13.1-cp27-cp27mu-manylinux1_x86_64.whl,scikit-image-0.13.1.tar.gz

可能遇見的問題 

 

1、(安裝skimage時)skimage\external\tifffile\tifffile.c(75) : fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory

原因: stdint.h是c99標准的頭文件,vc不支持,所以出現錯誤“No such file or directory”。

解決方法: 
①去我的資源中下載msinttypes-r26.zip,地址為:http://download.csdn.net/detail/atfuies/9887776解壓后得到3個文件:inttypes.h,stdint.h,changelog.txt 
②找到VC的include目錄,一般默認的VC for Python 的include位置為: 
C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include 
有的用戶名不是Administrator,將Administrator替換為你自己的用戶名。 
③將inttypes.h和stdint.h兩個文件放到VC for Python 的include文件中。

2、(pip install scikit-image時)error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27

原因:python通過pip或者源碼來安裝某些模塊時,這些模塊包含有c/c++源碼,安裝過程會調用本地的編譯器編譯這些代碼。

由於Python默認調用VS2008編譯器編譯相關C代碼,因此出現這種錯誤的原因可能有如下幾個方面:

(1)沒有安裝VS2008

(2)安裝了32位VS2008,使用64位python

解決方法:vs2008已經過時,直接指定更高版本的vs。先確保已安裝vs(如vs2013,vs2015等)。

指定方法打開 “python安裝目錄/Lib/distutils/msvc9compiler.py”文件,找到find_vcvarsall函數,在該函數開頭添加version =VS版本號(最好用pycharm編輯,文本編輯器容易出現空格,tab等造成的格式對齊問題),例如使用VS2013,則version = 12.0。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM