Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python cx_freeze&;设置工具_Python_Setuptools_Cx Freeze - Fatal编程技术网

Python cx_freeze&;设置工具

Python cx_freeze&;设置工具,python,setuptools,cx-freeze,Python,Setuptools,Cx Freeze,我想使用cx_freeze来冻结python应用程序,但我还想保留使用pip从源代码安装包的可能性。当我尝试在开发模式下安装包时(pip install-e.),我得到如下错误。cx_freeze似乎在后台使用distutils,而不是setuptools。是否可以强制cx\U冻结同时使用设置工具 D:\Python\FPF4Creator>pip install -e . You are using pip version 7.0.3, however version 7.1.2 is

我想使用cx_freeze来冻结python应用程序,但我还想保留使用pip从源代码安装包的可能性。当我尝试在开发模式下安装包时(
pip install-e.
),我得到如下错误。cx_freeze似乎在后台使用
distutils
,而不是
setuptools
。是否可以强制cx\U冻结同时使用设置工具

D:\Python\FPF4Creator>pip install -e .
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Obtaining file:///D:/Python/FPF4Creator
Requirement already satisfied (use --upgrade to upgrade): jinja2 in c:\winpython\python-2.7.6\lib\site-packages (from fpf4creator==0.0.2)
Requirement already satisfied (use --upgrade to upgrade): six in c:\winpython\python-2.7.6\lib\site-packages (from fpf4creator==0.0.2)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in c:\winpython\python-2.7.6\lib\site-packages (from jinja2->fpf4creator==0.0.2)
Installing collected packages: fpf4creator
  Running setup.py develop for fpf4creator
    Complete output from command C:\WinPython\python-2.7.6\python.exe -c "import setuptools, tokenize; __file__='D:\\Python\\FPF4Creator\\setup.py'; e
    xec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps:
  running develop
    Checking .pth file support in C:\Program Files (x86)\fpf4creator\Lib\site-packages\
      error: can't create or remove files in install directory

      The following error occurred while trying to add or remove files in the
      installation directory:

      [Error 5] Zugriff verweigert: 'C:\\Program Files (x86)\\fpf4creator'

      The installation directory you specified (via --install-dir, --prefix, or
      the distutils default setting) was:

      C:\Program Files (x86)\fpf4creator\Lib\site-packages\

      This directory does not currently exist.  Please create it and try again, or
      choose a different installation directory (using the -d or --install-dir
      option).


----------------------------------------
Command "C:\WinPython\python-2.7.6\python.exe -c "import setuptools, tokenize; __file__='D:\\Python\\FPF4Creator\\setup.py'; exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps" failed with error code 1 in D:\Python\FPF4Creator
setup.py
如下所示:

import os
from setuptools import find_packages
from cx_Freeze import setup, Executable

from fpf4creator import __version__


options = {
    'build_exe': {
        'include_files': 'fpf4creator/data',
    }
}

executables = [
    Executable('fpf4creator/gui.py', targetName='FPF4Creator.exe',
               icon='fpf4creator/data/gui/icon.ico', base="Win32GUI")
]


fpf4_data = []
for root, dirnames, filenames in os.walk('fpf4creator/data'):
    for fname in filenames:
        fpf4_data.append(os.path.join(root, fname).replace('fpf4creator/', ''))


setup(
    name='fpf4creator',
    version=__version__,
    author='Author',
    author_email='mail@author.com',
    packages=find_packages(),
    package_data={
        'fpf4creator': fpf4_data
    },
    install_requires=['jinja2', 'six'],
    entry_points={
        'gui_scripts': [
            'fpf4Creator = fpf4creator.gui:main',
        ],
    },
    options=options,
    executables=executables
)
(几年前,@ThomasK给出的答案作为一条评论被重新引用,因为它现在帮助了我)

您应该为cx冻结创建一个附加的安装文件。该文件的名称可以自由选择,但不应为
setup.py

不幸的是,您可能需要再次指定大多数设置参数。您还可以修改一个解决方案,利用以下事实从
setup.py
检索设置参数


我建议您有一个单独的
cx\u setup.py
文件用于冻结(不管它叫什么),还有一个用于Python打包工具的普通
setup.py
文件。有一种方法可以将cx\u Freeze类传递给setuptools,但是按照建议使用单独的文件就不那么麻烦了。
================== setup.py ==================

from setuptools import setup, find_packages
setup_arguments = { 'name': 'myapp', 'version': '0.0.0' }
if __name__ == '__main__' :
    setup( **setup_arguments )
================ setup_cx.py =================

from setup import setup_arguments
from cx_Freeze import setup
setup( **setup_arguments )