简体   繁体   English

是否可以使用pip模块在python 3项目上使用cx_freeze?

[英]Is it possible to use cx_freeze on a python 3 project using the pip module?

I am writing an installation program for a larger program I am writing, and I am using CxFreeze to convert it to an executable file, however, when I run the .exe file, it crashes with the line "import pip", and brings up (as shown below), so basically my question is: Is it possible to use CxFreeze on an application with pip imported? 我正在编写一个我正在编写的更大程序的安装程序,我正在使用CxFreeze将其转换为可执行文件,但是,当我运行.exe文件时,它崩溃了“import pip”行,并显示(如下所示),基本上我的问题是:是否可以在导入pip的应用程序上使用CxFreeze?

Edit: Here are all the files I am using: 编辑:这是我正在使用的所有文件:

setup.py (V1): setup.py(V1):

from cx_Freeze import *
import os, pip
setup(name=("ARTIST"),
      version = "1",
      description = "ARTIST installation file",
      executables = [Executable("Install ARTIST.py"), Executable("C:\\Python34\\Lib\\site-packages\pip\\__init__.py")],
      )

This brings up the error: 这会带来错误: 在此输入图像描述

setup.py (V2): setup.py(V2):

from cx_Freeze import *
import os, pip
setup(name=("ARTIST"),
      version = "1",
      description = "ARTIST installation file",
      executables = [Executable("Install ARTIST.py"],
      options = {"build_exe": {"packages":[pip]}}
      )

This brings up an error in the setup.bat file: 这会在setup.bat文件中出现错误: 在此输入图像描述

Edit: If anyone wants to look at the website where I am publishing the larger program, here is the link: alaricwhitehead.wix.com/artist 编辑:如果有人想查看我发布更大程序的网站,请点击链接: alaricwhitehead.wix.com/artist

Edit2: this is the error i get when i use py2exe: Edit2:这是我使用py2exe时得到的错误: 在此输入图像描述

Edit3: here is a copy of the code: https://www.dropbox.com/s/uu46iynm8fr8agu/Install%20ARTIST.txt?raw=1 Edit3:这是代码的副本: https ://www.dropbox.com/s/uu46iynm8fr8agu/Install%20ARTIST.txt?raw = 1

please note: I didn't want to have to post a link to it, but it was too long to post directly. 请注意:我不想发布链接,但直接发布太长了。

The are two problems in your setup script. 您的安装脚本中有两个问题。 The first problem is that you specified extra modules to include in your frozen application under the packages option of the build_exe command: packages is for specifying which packages of your application you need to include, for the external modules (such as pip ) you need to use includes . 第一个问题是您在build_exe命令的packages选项下指定了要包含在冻结应用程序中的额外模块: packages用于指定您需要包含的应用程序包,对于您需要的外部模块(如pip )使用includes The second problem is that you need to pass to includes a list of strings of modules and not the module itself: 第二个问题是你需要传递includes模块字符串列表而不是模块本身:

setup(
    name=("ARTIST"),
    version="1",
    description="ARTIST installation file",
    options={
        'build_exe': {
            'excludes': [], # list of modules to exclude
            'includes': ['pip'], # list of extra modules to include (from your virtualenv of system path),
            'packages': [], # list of packages to include in the froze executable (from your application)
        },
    },
    executables=[
        Executable(
            script='run.py', # path to the entry point of your application (i.e: run.py)
            targetName='ARTIST.exe', # name of the executable
        )
    ]
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM