Python执行ImportError:No module named MySQLdb异常

时间:2023-09-01 22:20:33
Python执行ImportError:No module named MySQLdb异常

Python执行ImportError:No module named MySQLdb异常

解决方法:

对于Linux来说,有多重包管理系统和安装机制。如果使用的是包含某种包管理器的Linux,那么可以很轻松的安装Python MySQLdb库。
Linux Fedora, CentOS系统:yum install MySQL-python
Linux Ubuntu操作系统:apt-get install python-mysqldb
Python执行ImportError:No module named MySQLdb异常

sudo pip install

The directory '/home/hancool/.cache/pip' or its parent directory is not owned by the current user and the cache has been disabled.

Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

解决方法:

直接 pip install django,不用sudo,权限的问题,对后续使用不影响。不管是用pip装什么模块,前面都尽量不要加sudo