centos6.8python2.7.13开发环境

操作系统版本:CentOS release 6.8
openssl版本:OpenSSL 1.0.1e-fips
python版本:python2.7.13


第一步.安装python2.7.13.tgz

[root@localhost home]wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
[root@localhost home]yum install -y openssl openssl-devel
[root@localhost home]tar -xf Python-2.7.13.tgz && cd Python-2.7.13

[root@localhost Python-2.7.13]./configure --prefix=/usr/local/python2.7.13
[root@localhost Python-2.7.13]sed -i '/#_socket socketmodule.c/a_socket socketmodule.c timemodule.c' Modules/Setup
[root@localhost Python-2.7.13]sed -i '/#_ssl _ssl.c/i_ssl _ssl.c -DUSE_SSL -I\$(SSL)\/include -I\$(SSL)\/include\/openssl -L\$(SSL)\/lib -lssl -lcrypto' Modules/Setup
[root@localhost Python-2.7.13]make && make install

[root@localhost Python-2.7.13]mv /usr/bin/python /usr/bin/python-2.6.6
[root@localhost Python-2.7.13]ln -s /usr/local/python2.7.13/bin/python2.7 /usr/bin/python

因为yum是依赖python的,所以这里我们修改了默认的python,就要要修改yum,让其运行指向旧的版本:

[root@localhost Python-2.7.13]sed -i "s/^#!\/usr\/bin\/python$/#!\/usr\/bin\/python-2.6.6/" /usr/bin/yum


第二步.安装setuptools
[root@localhost Python-2.7.13]cd /home/
[root@localhost home]wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
[root@localhost home]tar -xf setuptools-0.6c11.tar.gz && cd setuptools-0.6c11
[root@localhost setuptools-0.6c11]python setup.py build && python setup.py install


第三步.安装pip
pip 安装:
[root@localhost setuptools-0.6c11]cd /home/
[root@localhost home]wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
[root@localhost home]tar -xf pip-9.0.1.tar.gz && cd pip-9.0.1
[root@localhost pip-9.0.1]python setup.py install
[root@localhost pip-9.0.1]ln -s /usr/local/python2.7.13/bin/pip /usr/bin/pip

1.pip安装包
语法:
pip install 安装包名称

2.pip查看已安装的包
pip list --format=columns
pip show --files 安装包名称
#pip show --files pytz

3.pip检查哪些包需要更新
pip list --outdated --format=columns

4.pip升级包
pip install --upgrade 安装包名称

5.pip卸载包
pip uninstall 安装包名称


第四步.安装distribute nose virtualenv
1安装distribute
[root@localhost pip-9.0.1]pip install distribute

2.安装nose
[root@localhost pip-9.0.1]pip install nose

3.安装virtualenv
[root@localhost pip-9.0.1]pip install virtualenv

4.安装web框架
[root@localhost pip-9.0.1]pip install lpthw.web


第五步:创造python项目
1.创建python骨架
[root@localhost home]mkdir projects && cd projects/
[root@localhost projects]mkdir gothonweb && cd gothonweb && mkdir bin gothonweb tests docs templates
[root@localhost gothonweb]touch gothonweb/init.py
[root@localhost gothonweb]touch tests/init.py

2.在创建 app.py文件
vim bin/app.py加入以下内容

import web
urls = (
'/', 'index'
)
app = web.application(urls, globals())
class index:
def GET(self):
greeting = "Hello World"
return greeting
if name == "main":
app.run()

执行命令 python bin/app.py(不要切换目录执行)
注意:在所有的 python 项目中,你都不需要进到底层目录去运行东西。你应该停留在最上层目录运行,这样才能保证所有的模组和文件能被正常访问到。

出现以下情况即为成功

转载于:https://blog.51cto.com/yenokia/2083062

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值