我有一个使用pandas和sqlalchemy的小代码,并在我的main.py中声明为:
import pandas as pd
from sqlalchemy import create_engine
这是我完整的setup.py:
from distutils.core import setup
import py2exe
from glob import glob
data_files = [("Microsoft.VC90.CRT", glob(r'C:\Users\Flavio\Documents\Python_dll\*.*'))]
opts = {
"py2exe": {
"packages": ["pandas", "sqlalchemy"]
}
}
setup(
data_files=data_files,
options = opts,
console=['main.py']
)
我在终端中使用此命令:
python setup.py py2exe
但是当我运行main.exe时,它打开终端开始执行代码并突然关闭窗口。
当我在终端上运行时出现错误:
C:\Users\Flavio\Documents\python\python\untitled\dist>main.exe
Please add a valid tradefile date as yyyymmdd: 20150914
Traceback (most recent call last):
File "main.py", line 11, in <module>
File "C:\Users\Flavio\Anaconda3\lib\site-packages\sqlalchemy\engine\__init__.p
y", line 386, in create_engine
return strategy.create(*args, **kwargs)
File "C:\Users\Flavio\Anaconda3\lib\site-packages\sqlalchemy\engine\strategies
.py", line 75, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "C:\Users\Flavio\Anaconda3\lib\site-packages\sqlalchemy\connectors\pyodbc
.py", line 51, in dbapi
return __import__('pyodbc')
ImportError: No module named 'pyodbc'
答案 0 :(得分:0)
不知道你的程序是做什么的 我会尝试以下第一个 打开命令窗口并从那里运行.exe 窗口不会关闭,将显示任何错误消息(如果有)