我正在尝试编译python程序,我正在使用python 3.2.所以我下载了cx_freeze并安装了它.当我尝试在cmd中运行setup.py时,它说:
"importerror: no module named cx_freeze"
Run Code Online (Sandbox Code Playgroud)
我已经删除了cx_freeze并尝试重新安装它,但这次,在"选择应安装cx_freeze的位置"安装的一部分我从注册表中选择了python(这是我以前做过的)并且还选择了"python"从另一个位置"(并选择我的C:\ python32 \目录).然后我收到了这个错误:
"There is a problum with this windows installation package. a program required for this install to complete could not be run."
Run Code Online (Sandbox Code Playgroud)
注意:在我的setup.py文件中有以下内容:
from cx_freeze import *
Setup(
name = "",
version ="0.1",
description ="",
executables = [Executable("")] ,
)
Run Code Online (Sandbox Code Playgroud) 我正在尝试用cx_freeze和esky构建一个应用程序.它之前正在工作(好吧,也许几个月前.从那时起,python 3.5就灭了).
我有以下例外:
File "/usr/lib/python3.5/site-packages/esky/util.py", line 578, in compile_to_bytecode
loader = importlib._bootstrap.SourceLoader()
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceLoader'
Run Code Online (Sandbox Code Playgroud)
我正在使用:
我在Manjaro(Linux)上.我无法弄清楚问题的来源.你可以帮我一把吗?
我只是想知道是否可以更改cx_freeze脚本的程序图标,我环顾四周但我找不到任何东西.
我为客户编写了let脚本.为了不安装python和依赖包,我使用cx-freeze将所有内容打包到3个exe文件中.First - winservice,负责大部分工作.第二 - 设置向导.第三 - 与winservice合作的客户.面对任务,需要在安装包(使用bdist_msi制作)后在系统中注册服务,然后运行向导.怎么样?
我正在使用Flask开发一个python应用程序.目前,我希望这个应用程序在本地运行.它通过python在本地运行良好,但是当我使用cx_freeze将其转换为Windows的exe时,我不能再使用Flask.render_template()方法了.我尝试执行render_template的那一刻,我得到一个http 500错误,就像我正在尝试渲染的html模板不存在一样.
主python文件名为index.py.起初我试图跑:cxfreeze index.py
.这不包括cxfreeze"dist"目录中Flask项目的"templates"目录.那么我尝试使用这个setup.py脚本并运行python setup.py build
.现在包括templates文件夹和index.html模板,但在尝试渲染模板时仍然出现http:500错误.
from cx_Freeze import setup,Executable
includefiles = [ 'templates\index.html']
includes = []
excludes = ['Tkinter']
setup(
name = 'index',
version = '0.1',
description = 'membership app',
author = 'Me',
author_email = 'me@me.com',
options = {'build_exe': {'excludes':excludes,'include_files':includefiles}},
executables = [Executable('index.py')]
)
Run Code Online (Sandbox Code Playgroud)
以下是脚本中的示例方法:
@app.route('/index', methods=['GET'])
def index():
print "rendering index"
return render_template("index.html")
Run Code Online (Sandbox Code Playgroud)
如果我index.py
在控制台中运行,我得到:
* Running on http://0.0.0.0:5000/
rendering index
127.0.0.1 - - [26/Dec/2012 15:26:41] "GET / HTTP/1.1" 200 -
127.0.0.1 - …
Run Code Online (Sandbox Code Playgroud) 我有一个python脚本,它从互联网上获取图像,下载它,设置为桌面背景并在一分钟后更新.问题很可能是cx_Freeze不包括os模块,因为具有绝对路径的相同代码工作正常.我的代码也很完美,直到它冻结.它在我通过控制台加载,从IDLE运行或双击它之前冻结.每当我运行冻结文件时,我都会收到错误(如果我使用setup.py或cxfreeze file.py
:
C:\Python33\Scripts>C:\Python33\Scripts\dist\desktopchanger.exe
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "C:\Python33\desktopchanger.pyw", line 7, in <module>
dir = path.dirname(__file__)
NameError: name '__file__' is not defined
Run Code Online (Sandbox Code Playgroud)
import pythoncom
from urllib import request
from win32com.shell import shell, shellcon
from time import sleep
from os import path
dir = path.dirname(__file__) #get dierctory script is in
startpath = str(path.join(dir+'/bg/bg.jpg')) #add /bg/bg.jpg to path of script
pathtoimg=[]
for char in startpath:
if char != "/": …
Run Code Online (Sandbox Code Playgroud) 我有一个简单的PyGObject应用程序:
from gi.repository import Gtk
class Window(Gtk.Window):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_border_width(5)
self.button = Gtk.Button('Test')
self.box = Gtk.Box()
self.box.pack_start(self.button, True, True, 0)
self.add(self.box)
self.connect('delete-event', Gtk.main_quit)
self.show_all()
win = Window()
Gtk.main()
Run Code Online (Sandbox Code Playgroud)
我试图在Linux上使用cx_freeze使用以下setup.py
脚本冻结它:
from cx_Freeze import setup, Executable
setup(name="GUI Test",
description="GUITest",
version="0.1",
options={"build_exe": {"build_exe": "Bin/pygobject",
"create_shared_zip": False,
}},
executables=[Executable(script="hello_pygobject.py",
targetName="hello",
appendScriptToExe=True,
)]
)
Run Code Online (Sandbox Code Playgroud)
而我正在运行它: python3 setup_pygobject.py build
当我尝试运行冻结的应用程序时,我收到以下错误消息:
(process:22538): Gtk-CRITICAL **: gtk_settings_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)
我可能在目录中缺少一堆库,例如他们已经解释过Windows.我试图pmap
找到丢失的库.作为最后的手段,我还尝试将/usr/lib64/
(+其他一些我不记得的)的所有库复制到工作目录中.
有一个很好的方法如何找到我需要的库或一些更好的方法来解决它? …
我试图将.py脚本转换为.exe
cx_Freeze成功编译了exe.但是,当我运行exe文件时,它会抛出此错误:
ImportError:'appdirs'包是必需的; 通常,这与此软件包捆绑在一起,因此如果您收到此警告,请咨询您的分发包装商
这是我的setup.py
from cx_Freeze import setup, Executable
setup(
name = "dbx_sharelink" ,
version = "0.1" ,
description = " " ,
executables = [Executable("dbx_sharelink.py")] ,
)
Run Code Online (Sandbox Code Playgroud)
源代码Python脚本
import sys
import dropbox
import pandas as pd
import sys
import os
dbx = dropbox.Dropbox('xxxxxxxxxxxxxxxxx')
def getSharedLink(full_path):
try:
link = dbx.sharing_create_shared_link(full_path).url
except dropbox.exceptions.ApiError as err:
print('*** API error', err)
return None
return link
print(sys.argv[1])
link = getSharedLink("/A_DATA/data")
df = pd.DataFrame([{'link':link}])
df.to_clipboard(index=False,header=False)
os.system("pause")
Run Code Online (Sandbox Code Playgroud)
如何解决此错误?
我有一个复杂的图像处理脚本,使用Numpy和OpenCV在python中运行.我想在Android中运行此脚本,但我找不到办法.
经过一些研究后,我发现了一些可能有用的框架,但我遇到了一些问题:
我很乐意听到有关如何在Android中运行此脚本的一些想法.是否有可能根设备并安装Python,Numpy和OpenCV?
我无法将cx_freeze生成的.exe分发到另一台计算机,因为似乎exe包含对生成.exe的计算机上绝对路径的引用。我还必须直接包含vcruntime140.dll,因为"include_msvcr": True
没有复制文件。
以前已经以类似的形式问过这个问题,但没有答案:cx_Freeze复制路径
启动脚本时,出现以下错误(无法从窗口复制/粘贴,因此我共享图片)。您可以看到对绝对路径的引用,该引用C:\Program Files (x86)\Python....
显然不在另一台计算机上。
from os.path import dirname
from cx_Freeze import setup, Executable
from config import settings
import os.path
import sys
import glob
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
DEPENDENCY_DIR = os.path.join(os.getcwd(), 'dependencies')
os.environ['TCL_LIBRARY'] = os.path.join(DEPENDENCY_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(DEPENDENCY_DIR, 'tcl', 'tk8.6')
packages = ["sepa", "datev", "atexit", "shiboken2", "PySide2"]
includes = []
excludes = ["Pyside2.Qt5WebEngineCore.dll"]
includefiles = ['qt', 'settings', 'config', os.path.join(DEPENDENCY_DIR, 'DLLs', 'tk86t.dll'),
os.path.join(DEPENDENCY_DIR, …
Run Code Online (Sandbox Code Playgroud)