如何解决PyInstaller不包括sqlalchemy访问模块
我正在尝试将数据帧写回到Access数据库文件.mdb
或.accdb
中。我正在使用sqlalchemy
和sqlalchemy-access
创建连接。
import sqlalchemy
db_file_path = os.path.join(dir_path,f"data\\{graph_name}\\results\\{file_name}")
connection_string = (r'DRIVER={Microsoft Access Driver (*.mdb,*.accdb)};' f"DBQ={db_file_path};" r'ExtendedAnsisql=1;')
connection_url = f"access+pyodbc:///?odbc_connect={urllib.parse.quote_plus(connection_string)}"
engine = sqlalchemy.create_engine(connection_url)
text_labels.to_sql('InstTextLabels',engine,index=False,if_exists='append')
我通过pyodbc
安装了sqlalchemy-access
和pip
。如果我要在Python交互式shell或Jupyter Notebook中运行它,那么一切都可以。但是,当我使用PyInstaller构建一个文件可执行文件时,会得到:
File "solver.py",line 499,in main
export_results(file_name,graph_name,downstream_low,downstream_high,objective_results,objective_fuses,objective_recloseres,nodes,text_labels,dir_path)
File "solver.py",line 399,in export_results
engine = sqlalchemy.create_engine(connection_url)
File "sqlalchemy\engine\__init__.py",line 500,in create_engine
File "sqlalchemy\engine\strategies.py",line 61,in create
File "sqlalchemy\engine\url.py",line 172,in _get_entrypoint
File "sqlalchemy\util\langhelpers.py",line 267,in load
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:access.pyodbc
[5880] Failed to execute script solver
我不知道为什么这种情况持续发生。我的脚本仅导入sqlalchemy
,但我也将hiddenimports=['sqlalchemy_access','pyodbc']
包含在.spec
文件中。但是,没有任何帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。