如何将cx_oracle与Pyinstaller捆绑在一起 [英] How to bundle cx_oracle with Pyinstaller
问题描述
我的目标是使用Pyinstaller捆绑一个简单的python脚本中的exe文件,该脚本使用Tkinter和cx_oracle来访问数据库. python代码是在装有Anaconda,cx_oracle软件包和oracle客户端的Windows机器上开发的.然后,我需要在许多目标Windows计算机 oracle客户端或Python中运行exe文件.
My goal is to use Pyinstaller to bundle an exe file from a simple python script that uses Tkinter and cx_oracle to access a database. The python code is developed on a windows machine with Anaconda, cx_oracle package and oracle client installed. Then I need to run the exe file in many target windows machines without oracle client or Python.
我正在开发机器上使用Python 2.7和Pyinstaller 3.1.
I am using Python 2.7 and Pyinstaller 3.1 on the development machine.
我在网上搜索了很长一段时间,但只找到了一个关于此的教程: https://mail.python.org/pipermail/tutor/2014- December/103608.html
I searched quite a while online but only found one tutorial on this: https://mail.python.org/pipermail/tutor/2014-December/103608.html
我遵循相同的步骤,并修改了以下规格文件:
I followed the same procedure and modified the spec file as below:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['mycode.py'],
pathex=['C:\\Users\\myuser\\PycharmProjects\\mycode'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries + [('oraociei11.dll','D:\ProgramFiles\Anaconda2\oraociei11.dll','BINARY')],
a.zipfiles,
a.datas,
name='mycode',
debug=False,
strip=False,
upx=True,
console=True )
捆绑销售成功.该代码在安装了oracle客户端的原始计算机上运行.但是在没有oracle客户端的单独计算机上,它无法运行,并显示以下错误消息:
the bundle worked. The code runs on the original machine with oracle client installed. But on a separate machine without oracle client, it failed to run, with the below error message:
Tkinter回调中的异常 追溯(最近一次通话): 在调用中,文件"lib-tk \ Tkinter.py",第1537行 登录文件",第152行 DatabaseError:DPI-1047:无法加载64位Oracle Client库:找不到指定的模块".参见 https://oracle.github.io/odpi/doc/installation.html #windows 获取帮助
Exception in Tkinter callback Traceback (most recent call last): File "lib-tk\Tkinter.py", line 1537, in call File "", line 152, in login DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help
现在,我非常困惑需要哪些步骤才能安全地将Python脚本中的exe与cx_oracle捆绑在一起,以便它可以在没有oracle客户端的Windows计算机上运行?还是我必须"在目标计算机上安装oracle客户端?
Now I am very confused what are the required steps to safely bundle an exe from a python script with cx_oracle so that it can run on a windows machine without oracle client? Or do I "have to" install oracle client on the target machine?
我真的希望找到比上面我发现的旧链接更详细的教程,将pyinstaller与cx_oracle捆绑在一起.
I really hope to find a more detailed tutorial on bundling cx_oracle with pyinstaller than the old link I found above.
推荐答案
cx_Oracle需要Oracle客户端.您将需要将其安装在目标计算机上!请注意错误消息中的链接: https://oracle.github.io/odpi/doc/installation.html#windows .它应该可以帮助您解决使cx_Oracle在目标计算机上工作所需要做的一切.
cx_Oracle requires an Oracle client. You will need to install that on the target machine! Note the link in the error message: https://oracle.github.io/odpi/doc/installation.html#windows. It should help you out with everything you need to do to get cx_Oracle working on the target machine.
这篇关于如何将cx_oracle与Pyinstaller捆绑在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!