Linux下python&mysql的安装

依赖包的安装(不装后面可能会报错)

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl

官网下载解压包后解压

tar -xvf Python-3.6.5.tgz

解压完后cd进Python-3.6.5目录

cd Python-3.6.5
./configure
sudo make
sudo make install

顺便补充mysql安装

sudo apt-get install mysql-server
跟着指示安装完
输入mysql -uroot -p ,输入密码就可以进去mysql

python连接myql需要一个模块,这个模块在python2.x是mysql-python,在python3.x中是PyMySQL
安装命令:
2.x : pip install mysql-python

3.x : pip install PyMySQL,还需要在项目的__init__.py文件中导入一段代码:

import pymysql
pymysql.install_as_MySQLdb()

你可能感兴趣的:(django,linux)