请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

python3.6,我用pymysql代替mysql-python出现错误

我按照网上的步骤

__init__.py 加入:

import pymysql

pymysql.install_as_MySQLdb()

然后运行

python manage.py makemigrations

python manage.py migrate

出现如下错误

E:\workspace\pymysqltest>python manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "E:\Python\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "E:\Python\lib\site-packages\django\core\management\__init__.py", line 316, in execute
    settings.INSTALLED_APPS
  File "E:\Python\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
    self._setup(name)
  File "E:\Python\lib\site-packages\django\conf\__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "E:\Python\lib\site-packages\django\conf\__init__.py", line 97, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "E:\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "E:\workspace\pymysqltest\pymysqltest\__init__.py", line 1
    import pymysql
                 ^
SyntaxError: invalid character in identifier


请教一下如何处理

正在回答 回答被采纳积分+3

1回答

bobby 2017-01-31 11:23:12

你用卸载了pymsql 然后pip install mysqlclient尝试一下

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信