網上搜索了很多,主流的配置方法分為兩種:
摘自 1、http://www.jb51.net/article/83617.htm
安裝pip的包並確定pip安裝時的鏡像源地址,國內常用的地址有:
http://pypi.hustunique.com 華中理工大學
http://pypi.sdutlinux.org 山東理工大學
http://pypi.mirrors.ustc.edu.cn 中國科學技術大學
1> 臨時指定pypi鏡像源地址:
pip
install
--index-url=http:
//pypi
.jb51.net
/simple/
flask
但是對我Fedora21的系統來說,如安裝flask模塊的話:
pip3 install flask --find-links=http://mirrors.xxx.com.cn/pypi/simple/
批量安裝方法, 假如python需要的模塊全部填寫在requirement.txt中
PyMongo>=2.7 whoosh redis python-dateutil flask flask-login<=0.2.11 flask-pymongo tornado passlib xlrd lxml six>=1.9.0 pytz irc sleekxmpp Werkzeug Jinja2 itsdangerous click
pip3.4 install -r requirements.txt --index-url=http://mirrors.zte.com.cn/pypi/simple/
---------------------------------------------------------------------------------
備注:
如果使用pip安裝完成后發現模塊依賴的版本不滿足但安裝成功,代碼執行時報相關模塊不存在問題
(pyenv2.7) [root@localhost scripts]# python versionbuild/xxx_srpm_version_repo.py -v 5.04
Traceback (most recent call last):
File "versionbuild/recreate_srpm_version_repo.py", line 22, in <module>
from libs.lib import mount_update_repo, cd, CgslError, clean_env, gen_pkg_metadata, list_httplink_files, get_file_dir, \
File "/media/B/git/SVP/CGSL/scripts/libs/lib.py", line 9, in <module>
from fabric.api import env
File "/usr/lib/python2.7/site-packages/fabric/__init__.py", line 3, in <module>
from .connection import Config, Connection
File "/usr/lib/python2.7/site-packages/fabric/connection.py", line 16, in <module>
from paramiko.agent import AgentRequestHandler
File "/usr/lib/python2.7/site-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 91, in <module>
from paramiko.kex_curve25519 import KexCurve25519
File "/usr/lib/python2.7/site-packages/paramiko/kex_curve25519.py", line 6, in <module>
from cryptography.hazmat.primitives.asymmetric.x25519 import (
ImportError: No module named x25519
,這時可以采用更新模塊方法
(pyenv2.7) [root@localhost scripts]# pip install fabric --upgrade
Requirement already up-to-date: fabric in /usr/lib/python2.7/site-packages
Requirement already up-to-date: paramiko>=2.4 in /usr/lib/python2.7/site-packages (from fabric)
Requirement already up-to-date: invoke<2.0,>=1.1 in /usr/lib/python2.7/site-packages (from fabric)
Collecting cryptography>=1.1 (from fabric)
Downloading http://mirrors.zte.com.cn/pypi/packages/e6/68/50698ce24c61db7d44d93a5043c621a0ca7839d4ef9dff913e6ab465fc92/cryptography-2.7-cp27-cp27mu-manylinux1_x86_64.whl (2.3MB)
100% |████████████████████████████████| 2.3MB 9.9MB/s
Requirement already up-to-date: pynacl>=1.0.1 in /usr/lib64/python2.7/site-packages (from paramiko>=2.4->fabric)
Requirement already up-to-date: bcrypt>=3.1.3 in /usr/lib64/python2.7/site-packages (from paramiko>=2.4->fabric)
Collecting asn1crypto>=0.21.0 (from cryptography>=1.1->fabric)
Downloading http://mirrors.zte.com.cn/pypi/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
100% |████████████████████████████████| 102kB 11.9MB/s
Collecting enum34; python_version < "3" (from cryptography>=1.1->fabric)
Downloading http://mirrors.zte.com.cn/pypi/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting ipaddress; python_version < "3" (from cryptography>=1.1->fabric)
Downloading http://mirrors.zte.com.cn/pypi/packages/fc/d0/7fc3a811e011d4b388be48a0e381db8d990042df54aa4ef4599a31d39853/ipaddress-1.0.22-py2.py3-none-any.whl
Collecting cffi!=1.11.3,>=1.8 (from cryptography>=1.1->fabric)
Downloading http://mirrors.zte.com.cn/pypi/packages/8d/e9/0c8afd1579e5cf7bc0f06fbcd7cdb954cbc0baadd505973949a99337da1c/cffi-1.12.3-cp27-cp27mu-manylinux1_x86_64.whl (415kB)
100% |████████████████████████████████| 419kB 3.4MB/s