标签: cx-freeze

cx_freeze 模块依赖

所以我的 python 脚本依赖于我创建的另一个模块。该模块读取文本文件。当我从源代码运行并且一切正常时,脚本、模块和它读取的文件通常位于同一目录中。

我用cx_freeze编译,当我运行它时,导入的模块失败。该模块尝试读取该文件并表示找不到它,然后一切就停止了。

该文本文件包含在library.zip 和构建文件夹中(可能没有必要,但我认为这不会有什么坏处)。我决定在读取文件之前打印模块中的工作目录以查看发生了什么,看起来工作目录不是构建文件夹,而是我的用户主目录。

当然,该文本文件不在我的用户的主目录中。我怎样才能解决这个问题?

具体来说,这是一个例子。所有文件都位于同一目录中。

脚本.py:

import hello
Run Code Online (Sandbox Code Playgroud)

你好.py

import os
print(os.getcwd())
f = open('hello.txt','r')
print(f.read())
f.close()
Run Code Online (Sandbox Code Playgroud)

你好.txt

hello!
Run Code Online (Sandbox Code Playgroud)

安装程序.py

import sys
import os
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.

includes = ['hello.txt']
zip_inc = ['hello.txt']

build_exe_options = {"packages": ["os"], "include_files": includes, "zip_includes": zip_inc}

setup(  name = "test",
        version = "0.1",
        description = "test",
        options = {"build_exe": build_exe_options},
        executables = [Executable("script.py")])
Run Code Online (Sandbox Code Playgroud)

我用命令构建:

python setup.py build
Run Code Online (Sandbox Code Playgroud)

然后我在构建目录中运行名为 script …

python cx-freeze

1
推荐指数
1
解决办法
2709
查看次数

运行使用 cx_freeze 制作的 tkinter exe 时出错

我正在尝试使用 cx_Freeze 从用 Python 3.5 编写的脚本创建一个独立的 exe,以便能够在没有 Python 的计算机上运行它。

该程序本身只是一个使用 tkinter 的具有简单 UI 的小型计算器。我使用的是 Windows 10。

我创建了一个看起来像这样的安装脚本。

import sys
from cx_Freeze import setup, Executable
# replaces commandline arg 'build'
sys.argv.append("build")

filename = "Widgets_tmp.py"
base = None
if sys.platform == "win32":
    base = "Win32GUI"
setup(
    name = "Widgets",
    version = "1.0",
#   options={"build_exe": {"packages": ["tkinter"]}},
    description = "cx_Freeze Tkinter script",
    executables = [Executable(filename, base=base)])
Run Code Online (Sandbox Code Playgroud)

这运行没有问题,直到我尝试运行 exe。然后我收到这个错误:

Traceback (most recent call last):
  File "C:\python64\lib\site-packages\cx_freeze\initscripts\Console.py"
line 21, in <module>
    exec(code, m.__dict__)
  File "Widgets_tmp.py", …
Run Code Online (Sandbox Code Playgroud)

python windows tkinter cx-freeze python-3.5

1
推荐指数
1
解决办法
5571
查看次数

python cx_freeze问题ascil

我想用py2exe或制作EXE文件cx_freeze.

所以我试着用py2exe制作exe文件,但没有运气.

所以现在我正在测试,cx_freeze但它也失败了.

如果有人可以帮助我很多apprecaite

以下是cx_freeze 来自cx_Freeze导入设置,可执行文件的setup.py文件

copyDependentFiles=True
silent = True
includes = ["lxml", "lxml._elementpath", "lxml.etree", "gzip", "encodings.cp949", "encodings.utf_8", "encodings.ascii"]
setup(name='gearfacts',

     options = {
       "build_exe" : {
           "includes": includes,
           },
       },
     executables=[Executable('test.py')],
     ) 
Run Code Online (Sandbox Code Playgroud)

以下是我的脚本源文件.

- - 编码:utf-8 - -

import lxml,cookielib,urllib,configobj,sys,getopt,string,mechanize,time,os 
from lxml import etree
from lxml.html import parse, fromstring
import sys, getopt, string  
import lxml.html
import encodings.utf_8
import encodings.euc_kr 
import encodings.cp949

br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True) …
Run Code Online (Sandbox Code Playgroud)

python cx-freeze

0
推荐指数
1
解决办法
3879
查看次数

使用python和pygame使用cx_freeze创建.exe时出现问题,包括其他文件

我在使用cx_Freeze创建.exe文件时遇到问题.我正在尝试使用这个需要一些.png,.gif和.ogg的Pygame游戏.我试图使用commmand行和setup.py来编译一个简单的Python(没有pygame或其他文件),但是既没有工作也没有我的死亡.

我已经安装了cx_Freeze并检查它是否与IDLE中的'import cx_freeze'一起使用而不会引发错误.我在Windows 7上使用Python 3.3,使用正确版本的pygame和cx_freeze作为我的python版本.

任何人都可以帮我创建这个.exe吗?

python pygame cx-freeze

0
推荐指数
1
解决办法
8812
查看次数

什么是运行时错误?

我用 Python 2.6 制作了一个游戏。我还使用 cx_Freeze 4.3 将它变成了可执行文件。当我在我的计算机上运行可执行文件时,它想出了这个:

Microsoft Visual C++ Runtime Library

Program: C:\Users\smm\Desktop\asteroid shower 1.4.5\asteroid.exe


This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Run Code Online (Sandbox Code Playgroud)

我不明白这里发生了什么。我试图解决这个问题,但没有运气。然后我在谷歌上搜索了运行时错误,它说可能是兼容性问题。我在 windows vista 上用下载的 windows 7 python 2.6 版本编写了原始脚本。我这样做是因为 windows vista 没有互联网,所以我在 windows 7 笔记本电脑上下载了 python、pygame 和 cx_freeze .msi 文件。然后我将文件传输到桌面 windows vista。这是问题吗?或者可能是脚本?我不认为它是脚本,因为当它仍然是 python 脚本时我可以玩游戏。虽然它有点长......我使用python 2.6,pygame 2.6和cx_freeze 4.3运行Windows 7。谢谢你,如果你能帮助我:)。

    # By Sandy Goetjens
# Asteroid Shower V1.4.5

import pygame, random, sys, time
from …
Run Code Online (Sandbox Code Playgroud)

python compatibility pygame windows-vista cx-freeze

-1
推荐指数
1
解决办法
3万
查看次数