ImportError: cannot import name 'pymysql' from 'sqlalchemy' (E:\Program Files (x86)\Anaconda3\lib\site-packages\sqlalchemy\__init__.py
时间: 2023-08-23 09:04:19 浏览: 186
ImportError:无法从“django.utils.encoding”导入名称“force text”Python 错误
引用中提到了在解决`ImportError`的问题上有一个解决办法,即在MySQLdb.py文件中添加`import pymysql`和`pymysql.install_as_MySQLdb()`。这样可以将MySQLdb替换为PyMySQL来解决该错误。
引用中提到了另外一种解决方法,即使用PyMySQL代替MySQLdb来连接数据库。通过执行`pip install PyMySQL`命令安装PyMySQL,并将数据库连接改为`mysql+pymysql://root:123455@192.168.10.44/test?charset=utf8`。
引用提供了一个链接,其中可以下载适用于Windows的Python扩展包,其中包括了针对不同Python版本和位数的MySQL客户端库。你可以根据自己的情况选择合适的版本来解决问题。
所以,你可以尝试上述的两种方法来解决`ImportError: cannot import name 'pymysql' from 'sqlalchemy'`的问题。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* [ImportError: No module named 'MySQLdb'](https://blog.csdn.net/weixin_39777626/article/details/79133130)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* [superset(一)详细部署步骤(python 3.7.15、windows11)及验证异常处理](https://blog.csdn.net/chenwewi520feng/article/details/131516262)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *3* [Windows Superset 填坑记](https://blog.csdn.net/redfox1985/article/details/122123286)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文