metroluffy / blog

用于记录平时开发中所遇到问题的解决方法、笔记等
9 stars 1 forks source link

Centos下安装 MySQLdb #8

Open metroluffy opened 6 years ago

metroluffy commented 6 years ago

在新的Centos下安装MySQL-python,如果直接一把梭yum install MySQL-python,可能会遇见错误。因此在此之前你需要先安装Gcc、python-devel、 mysql-devel

# Install Gcc
yum install gcc

# Install Python devel packages

yum install python-devel

# Install MySQL devel packages

yum install mysql-devel

一些错误

  1. 在运行时,使用import MySQLdb 时报:

ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

>>> find / -name libmysqlclient.so.18
>>> ln -s /path/libmysqlclient.so.18  /usr/lib/libmysqlclient.so.18
>>> ldconfig  # 立即生效

类似的错误解决方法差不多

参考资料

  1. Centos下安装MySQLdb若干错误总结
  2. Installing mysql-python on Centos