all kinds of inquiries about all kinds of installations, there are a lot of bad ones, but they still report an error
. system: centos7
Framework: tornado
error message
Traceback (most recent call last):
File "/home/king/PycharmProjects/untitled4/server.py", line 5, in <module>
import torndb
File "/home/king/PycharmProjects/untitled/untitled4/lib/python3.5/site-packages/torndb.py", line 33, in <module>
import MySQLdb.constants
ImportError: No module named "MySQLdb"
Program Code
-sharp coding:utf-8
import tornado.web
import tornado.ioloop
import torndb
class IndexHandler(tornado.web.RequestHandler):
""""""
def get(self):
"""httpget"""
self.db = torndb.Connection(
host="127.0.0.1",
database="itcast",
user="root",
password="root"
)
self.db.execute("create database test1 ")
self.write("Hello Itcast!")
if __name__ == "__main__":
app = tornado.web.Application([
(r"/", IndexHandler),
])
app.listen(8000)
tornado.ioloop.IOLoop.current().start()
torndb has been installed
(untitled4) [king@localhost untitled4]$ pip3 install torndb
Requirement already satisfied: torndb in /home/king/PycharmProjects/untitled/untitled4/lib/python3.5/site-packages
MySQL-python has been installed
(untitled4) [king@localhost untitled4]$ sudo yum install MySQL-python
[sudo] password for king:
:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: ftp.yz.yamagata-u.ac.jp
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
MySQL-python-1.2.5-1.el7.x86_64