我使用pyinstaller创建了一个可执行文件。我的脚本都运行得很好,但是当我运行可执行文件时,我得到了下面的错误。它看起来不像DBconnection.py中的mysql连接器。任何帮助都是非常感谢的。
回溯(最近一次调用):文件"main.py",第8行,位于文件"c:\programdata\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_i mporters.py中,第631行,位于exec_module文件"DBconnection.py",第2行,位于ModuleNotFoundError中:没有名为'mysql‘4780的模块无法执行主脚本。
DBconnection.py:
from configparser import ConfigParser
from mysql.connector import MySQLConnection
import Global
def create_db_connection(filename= 'my.ini', section= 'dbconnection'):
parser = ConfigParser()
parser.read(filename)
db = {}
if parser.has_section(section):
items = parser.items(section)
for item in items:
db[item[0]] = item[1]
else:
raise Exception('{0} not found in the {1} file'.format(section. filename))
#global conn
Global.conn = MySQLConnection(**db)
print(Global.conn)
def close_db_connection():
Global.conn.close()main.py:
from servers import updateservers
from policies import updatepolicies
from updateguardpoints import updateguardpoints
from activities import updateactivities
from guardpointstatus import updateguardpointstatus
from application import updateapplication
from application_servers import updateapplication_servers
from DBconnection import create_db_connection
from DBconnection import close_db_connection
from TrouxConnection import TrouxConnection
from TrouxConnection import CloseTrouxConnection
import Global
create_db_connection()
TrouxConnection()
updateservers()
updatepolicies()
updateguardpoints()
updateactivities()
updateguardpointstatus()
updateapplication()
updateapplication_servers()
CloseTrouxConnection()
close_db_connection()发布于 2019-04-04 21:25:43
已使用PIP重新安装mysql - connector。问题已解决
https://stackoverflow.com/questions/55483144
复制相似问题