CENTOS 安装 Python 2.7 总结

来源:互联网 发布:弱电箱网络模块怎么用 编辑:程序博客网 时间:2024/06/03 21:35

1、安装 sqlite-devel

因为 Flask 应用程序可能使用能 Sqlite 数据库,所以这个得装上(之前因为没装这个,导致 Python 无法导入 sqlite3 库。

当然,也可以从源码编译安装。

yum install sqlite-devel -y

2、安装 Python 2.7

wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgztar xf Python-2.7.8.tgzcd Python-2.7.8./configure --prefix=/usr/localmake && make install

安装成功之后,你可以在 /usr/local/bin/python2.7 找到 Python 2.7。

3、环境变量


到/usr/bin/中删除里面的python文件,然后再在该目录下创建2.6的一个symbolic link就可以让系统执行我们想要的2.6版本了,如下:

[root@localhost bin]# pythonPython 2.7.8 (default, Apr 26 2017, 14:31:37)[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2Type "help", "copyright", "credits" or "license" for more information.

4、安装 setuptools + pip



wget --no-check-certificat  https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz

# Then install it for Python 2.7 :python ez_setup.py# Now install pip using the newly installed setuptools:easy_install pipll# With pip installed you can now do things like this:pip2.7 install [packagename]pip2.7 install --upgrade [packagename]pip2.7 uninstall [packagename]

0 0
原创粉丝点击