【问题标题】:Compiling Cx-Freeze under Ubuntu在 Ubuntu 下编译 Cx-Freeze
【发布时间】:2014-09-26 06:41:03
【问题描述】:

一整天我都在尝试在 Ubuntu 14.04 下编译 cx-Freeze 并且没有运气。所以我放弃了,决定在这里请教专家。

我有什么

  1. Ubuntu 14.04
  2. Python 3.4
  3. 安装了python-dev、python3-dev、python3.4-dev(我知道这个常见问题)
  4. cx-Freeze 4.3.3 的来源

我尝试了两种方法:

  1. 从源安装
  2. 通过 pip 安装

从源安装

sudo python3 setup.py install

我得到了什么

很多

MyPath/cx_Freeze-4.3.3/source/bases/Console.c:24: undefined reference to `PyErr_Print'
MyPath/cx_Freeze-4.3.3/source/bases/Console.c:24: undefined reference to `Py_FatalError'

然后

collect2: error: ld returned 1 exit status
error: command 'i686-linux-gnu-gcc' failed with exit status 1

通过 pip 安装

sudo pip3 install cx-Freeze

我得到了什么

collect2: error: ld returned 1 exit status

错误:命令“i686-linux-gnu-gcc”失败,退出状态为 1

----------------------------------------
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cx-Freeze/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-c954v7x6-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cx-Freeze
Storing debug log for failure in /home/grimel/.pip/pip.log

在 pip.log 中

Exception information:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/pip/req.py", line 706, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python3/dist-packages/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cx-Freeze/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-c954v7x6-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cx-Freeze

所以,我希望你能帮助我解决这个问题,并且会非常感激:)

【问题讨论】:

  • 不使用package的任何特殊原因?
  • 也许我是个极客。谁知道?
  • 如果您查看我上面链接到的页面,您可以找到所需的包,以及他们必须申请的差异才能使其编译。这可能会有所帮助。
  • 这是一个known issue,与 Debian/Ubuntu 在 distutils 中的一些变化有关。该问题链接有一个解决方法。
  • @ThomasK:非常感谢!这对我有用。

标签: python linux ubuntu executable cx-freeze


【解决方案1】:

setup.py 字符串中

if not vars.get("Py_ENABLE_SHARED", 0):

替换为

if True:

感谢 Thomas K

【讨论】:

  • 我在 setup.py 文件中找不到 if not vars.get("Py_ENABLE_SHARED", 0): 语句
【解决方案2】:

来自cx_freeze/issues

下载

你需要download the source code

对于 python 3.3 和 3.4:

  1. sudo apt-get install python3-dev

  2. sudo apt-get install libssl-dev

  3. 打开 setup.py 并更改行

    if not vars.get("Py_ENABLE_SHARED", 0):

    if True:

  4. python3 setup.py build

  5. sudo python3 setup.py install

对于 python 2.7:

  1. sudo apt-get install python-dev

  2. sudo apt-get install libssl-dev

  3. 打开 setup.py 并更改行

    if not vars.get("Py_ENABLE_SHARED", 0):

    if True:

  4. python setup.py build

  5. sudo python setup.py install

【讨论】:

    【解决方案3】:

    GriMel 的回答对我有用。在 cx_freeze 为此发布更新之前,我将包含一组步骤,您可以使用 GriMels 的解决方案来执行这些步骤。

    # create and activate virtualenv (as desired)
    virtualenv envs/test_cxfreeze
    . ./envs/test_cxfreeze/bin/activate
    
    # download cxfreeze; do not install yet 
    mkdir src/ 
    pip install --download=./src/ cx-freeze
    tar zxvf ./src/cx_Freeze-4.3.4.tar.gz -C ./src/
    
    # fix bug in setup.py
    vim src/cx_Freeze-4.3.4/setup.py
    84c84
    <             if True:
    ---
    >             if not vars.get("Py_ENABLE_SHARED", 0):
    
    # install cxfreeze
    pip install ./src/cx_Freeze-4.3.4/
    

    我还打开了一个似乎是源代码库的 bitbucket 问题。

    https://bitbucket.org/anthony_tuininga/cx_freeze/issues/153/cx_freeze-434-compile-error-on-ubuntu-1404
    

    【讨论】:

    • 按照您的说明安装后,它将安装,但尝试冻结一个小的 hello world 脚本(在 python2 上与 cx freeze 一起使用失败),我使用的是 ubuntu 12.04,但 cx_Freeze.freezer.ConfigError: no基地命名控制台
    【解决方案4】:

    看起来你可能有错字 改变

     sudo pip3 install cx-Freeze
    

     sudo pip3 install cx_Freeze
    

    【讨论】:

    • cx-Freezecx_Freeze 在这里是一样的。
    • 安装 --record /tmp/pip-nr20fmvl-record/install-record.txt --single-version-externally-managed --compile" 失败,错误代码 1 在 /tmp/pip- build-8b_mhb24/cx-Freeze/
    猜你喜欢
    • 2020-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多