gpt4 book ai didi

python - cx_freeze : How do I resolve conflicts caused by multiple . 同名dylib文件

转载 作者:行者123 更新时间:2023-12-04 17:23:13 26 4
gpt4 key购买 nike

我已经创建了一个 python 应用程序,现在我想将它变成一个独立的应用程序。我正在使用 virtualenv 中的 cx_freeze,它以前在我的机器上使用依赖性较低的脚本运行。

我目前遇到一个问题,当它尝试将同名的 dylib 文件复制到构建文件夹时,cx_freeze 出错。

我正在运行命令:

python3 setup.py build

我的 setup.py 文件如下所示:

from cx_Freeze import setup, Executable

build_options = {'packages': ["PySimpleGUI", "matplotlib", "pandas", "descartes", "geopandas", "cities_coordinates"],
#'excludes': ["PIL", "pyproj", "setuptools"],
"zip_exclude_packages": [],}

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
Executable('main.py', base=base, targetName = 'data_visualizer')
]

setup(name='data_visualizer',
version = '0.1',
description = 'Data visualization tool',
options = {'build_exe': build_options},
executables = executables)

这是我遇到的错误:

...
copying /Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/fiona/.dylibs/libproj.12.dylib -> build/exe.macosx-10.9-x86_64-3.7/libproj.12.dylib
copying /Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/fiona/.dylibs/libjson-c.2.dylib -> build/exe.macosx-10.9-x86_64-3.7/libjson-c.2.dylib
Traceback (most recent call last):
File "setup.py", line 18, in <module>
executables = executables)
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/dist.py", line 392, in setup
distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/dist.py", line 260, in run
freezer.Freeze()
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/freezer.py", line 788, in Freeze
self._WriteModules(fileName, self.finder)
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/freezer.py", line 712, in _WriteModules
relativeSource=True,
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/freezer.py", line 231, in _CopyFile
resolvedPath=dependent_file
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/freezer.py", line 231, in _CopyFile
resolvedPath=dependent_file
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/freezer.py", line 173, in _CopyFile
sourcePath=normalizedSource, targetPath=normalizedTarget
File "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/cx_Freeze/darwintools.py", line 446, in getDarwinFile
raise DarwinException(exceptionString)
cx_Freeze.darwintools.DarwinException: Attempting to copy two files to "build/exe.macosx-10.9-x86_64-3.7/libwebp.7.dylib"
source 1: "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/PIL/.dylibs/libwebp.7.dylib" (real: "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/PIL/.dylibs/libwebp.7.dylib")
source 2: "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/fiona/.dylibs/libwebp.7.dylib" (real: "/Users/AidenTheJaunty/projects/test/lib/python3.7/site-packages/fiona/.dylibs/libwebp.7.dylib")
(This may be caused by including modules in the zip file that rely on binary libraries with the same name.)

如果我排除引入与另一个 dylib 冲突的库(请参阅 setup.py 中注释掉的排除构建选项),那么该命令将成功运行,但我构建的应用程序将由于缺少依赖项而失败。

有谁知道解决这个问题的方法吗?

一些其他信息(如果重要的话)->

操作系统: Mac OS Big Sur
Python版本:3.7.8
cx_freeze 版本:6.2

最佳答案

似乎已在此 cx_Freeze issue 中报告了同名错误,由此介绍pull request将第二个文件复制到另一个文件的路径时会引发错误。

A workaround被合并以打印警告并简单地使用文件的第一个副本而不是引发错误。由于它似乎尚未发布(截至 2021 年 3 月 9 日,v6.5.3),我从 Git 安装了 cx_Freeze(在克隆并进入 repo 后,我通过 pip install -e 安装了它。 ),运行 cxfreeze,并看到如下警告:

*** WARNING ***
Attempting to copy two files to '../distcx/libopenblas.0.dylib'
source 1: '/venv/lib/python3.6/site-packages/numpy/.dylibs/libopenblas.0.dylib' (real: '/venv/lib/python3.6/site-packages/numpy/.dylibs/libopenblas.0.dylib')
source 2: '/venv/lib/python3.6/site-packages/scipy/.dylibs/libopenblas.0.dylib' (real: '/venv/lib/python3.6/site-packages/scipy/.dylibs/libopenblas.0.dylib')
(This may be caused by including modules in the zip file that rely on binary libraries with the same name.)
Using only source 1.

冲突文件被简单地跳过,允许构建继续进行。

关于python - cx_freeze : How do I resolve conflicts caused by multiple . 同名dylib文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64962237/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com