Traceback (most recent call last): File "log2user-real.py", line 49, in <module> db = create_engine("mysql+pymysql://root:{m_pass}@10.157.2.25:8306/log_user?charset=utf8".format(m_pass=m_pass)) File "<string>", line 2, in create_engine File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned return fn(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/create.py", line 548, in create_engine dbapi = dialect_cls.dbapi(**dbapi_args) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/pymysql.py", line 68, in dbapi return __import__("pymysql") File "build/bdist.linux-x86_64/egg/pymysql/__init__.py", line 59, in <module> File "/usr/local/lib/python2.7/site-packages/PyMySQL-1.0.2-py2.7.egg/pymysql/connections.py", line 167 *, ^ SyntaxError: invalid syntax
原因:PyMySQL的最新版,不支持Python 2.7
解决方法:指定PyMySQL版本为0.10.1,requirements.txt文件中写入:PyMySQL==0.10.1
pip install pymysql==0.10.1
参考:https://github.com/PyMySQL/PyMySQL/blob/master/CHANGELOG.md
标签:py,pymysql,报错,PyMySQL,File,line,167,local From: https://www.cnblogs.com/Primzahl/p/16948224.html