python django环境配置

Python Django环境配置

环境: CentOS 6.5,之后要用到MySQL

为了防止以后安装其它模块,所以先装了个pip

1 安装python

下载:

sudo wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz

解压:

tar zxvf Python-2.7.10.tgz

安装

cd Python-2.7.10
./configure –prefix=/usr/local/Python-2.7.10/
sudo make
sudo make install

创立软连接:

ln -s /usr/local/Python-2.7.10/bin/python /usr/bin/python -f

如果要还原到 2.6,就用下面的

sudo ln -s /usr/bin/python2.6 /usr/bin/python -f

2 安装setuptools

wget https://pypi.python.org/packages/source/s/setuptools/setuptools-17.1.1.tar.gz#md5=7edec6cc30aca5518fa9bad42ff0179b
sudo tar zxvf setuptools-17.1.1.tar.gz
cd setuptools-17.1.1
python ez_setup.py

或者

python setup.py install

成功安装显示:
Finished processing dependencies for setuptools==17.1.1

3 安装pip

下载

wget https://pypi.python.org/packages/source/p/pip/pip-7.0.3.tar.gz#md5=54cbf5ae000fb3af3367345f5d299d1c–no-check-certificate

安装

tar -xzvf pip-7.0.3.tar.gz
cd pip-7.0.3
python setup.py install

如果找不到pip先试试这一步,不行再看后面的问题

ln -s /usr/local/Python-2.7.10/bin/pip /usr/local/bin

4 安装Django

cd pip-7.0.3
sudo pip install Django

检验:

import django

如果能成功导入说明安装成功

5 安装mysql connector

wget http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
unzip mysql-connector-python-2.0.4.zip

cd mysql-connector-python-2.0.4
python setup.py install

检验:

import mysql.connector

部署到服务器

a) 上传代码到我的目录 /home/recommend-chen/schoolRecommend
b) 启动服务
cd /home/recommend-chen/schoolRecommend
python manage.py runsever 0.0.0.0:8009

问题 1:sqlite相关问题

下载 sqlite-autoconf-3081002.tar.gz

wget http://www.sqlite.org/2015/sqlite-autoconf-3081002.tar.gz
./configure
make
make install

问题 2:使用pip报No module named ‘pip._vendor.requests’

现象:
No module named ‘pip._vendor.requests’

yum install openssl-devel

然后重新make python

问题3: No module named yum

修改文件:

vi /usr/bin/yum

修改头 #!/usr/bin/python => #!/usr/bin/python2.6

问题4:缺少zlib

现象:
“Compression requires the (missing) zlib module”

yum install zlib-devel
yum install zlib

然后重新make python
或者手动安装:

wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
tar -xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure –prefix=/usr/local/zlib
vi /etc/ld.so.conf.d/zlib.conf
/usr/local/zlib/lib

问题5: 缺少 unzip

现象:
-bash: unzip: command not found

yum install -y unzip zip

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页