一、环境
[root@localhost myproject]# cat /proc/version
centos6.5
Linux version 2.6.32-642.11.1.el6.i686
(mockbuild@c1bm.rdu2.centos.org) (gcc version 4.4.7 20120313 (Red
Hat 4.4.7-17) (GCC) ) #1 SMP Fri Nov 18 18:48:28 UTC 2016
二、操作
1、
yum
groupinstall
"Development
tools"
2、
yum
install
zlib-devel
bzip2-devel
openssl-devel ncurses-devel sqlite-devel
3、
替换默认的python2.6.6
mv
/usr/bin/python /usr/bin/python2.6.6
vim
/usr/bin/yum将#!/usr/bin/python
替换成#!/usr/bin/python2.6.6(因为python2.7不支持yum)
wget
https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar vxf Python-2.7.11.tgz
cd Python-2.7.11.tgz
./configure --prefix=/usr/local
make && make install
4、安装pip
第一种方法(离线安装)
wget
https://pypi.python.org/packages/ff/d4/209f4939c49e31f5524fa0027bf1c8ec3107abaf7c61fdaad704a648c281/setuptools-21.0.0.tar.gz#md5=81964fdb89534118707742e6d1a1ddb4
tar vxf setuptools-21.0.0.tar.gz
cd setuptools-21.0.0
python setup.py install
第二种方法(在线安装)
wget https://bootstrap.pypa.io/get-pip.pypython2.7
get-pip.py
修改环境变量
vim /etc/profile添加export PATH=$PATH:/hom
e/wang/Python2.7.10/bin执行生效source
/etc/profile
执行pip查看结果
[root@localhost myproject]# pip
Usage:
pip [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.
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 to a
verbose appending log.
--proxy
Specify a proxy in the
form
[user:passwd@]proxy.server:port.
--retries
Maximum
number of retries each connection should
attempt
(default 5 times).
--timeout
Set the socket timeout
(default 15 seconds).
--exists-action
Default action when a path already exists:
(s)witch,
(i)gnore, (w)ipe, (b)ackup, (a)bort.
--trusted-host Mark this
host as trusted, even though it does not
have valid
or any HTTPS.
--cert
Path to
alternate CA bundle.
--client-cert
Path to SSL
client certificate, a single file
containing
the private key and the certificate in
PEM
format.
--cache-dir
Store the
cache data in
.
--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.
5、参考网址:http://docs.jinkan.org/docs/flask/installation.html#virtualenv
pip install virtualenv
$ mkdir myproject
$ cd myproject
$ virtualenv venv
New python executable in venv/bin/python
Installing distribute............done.
$ . venv/bin/activate
$ pip install Flask