简体   繁体   English

在Ubuntu下编译Cx-Freeze

[英]Compiling Cx-Freeze under Ubuntu

For the entire day I have been attempting to compile cx-Freeze under Ubuntu 14.04 and had no luck. 整整一天,我一直在尝试在Ubuntu 14.04下编译cx-Freeze并且没有运气。 So I gave up and decided to ask experts here. 所以我放弃了,决定在这里问专家。

What I have 是)我有的

  1. Ubuntu 14.04 Ubuntu 14.04
  2. Python 3.4 Python 3.4
  3. python-dev, python3-dev, python3.4-dev installed (I know this common issue) python-dev,python3-dev,python3.4-dev安装(我知道这个常见问题)
  4. Sources of cx-Freeze 4.3.3 cx-Freeze的来源4.3.3

I tried two ways: 我试过两种方法:

  1. install from the sources 从源头安装
  2. install by pip 由pip安装

Install from the sources 从源安装

sudo python3 setup.py install

What I got 我得到了什么

a lot of 许多

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'

and then 然后

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

Install by pip 通过pip安装

sudo pip3 install cx-Freeze

What I got 我得到了什么

collect2: error: ld returned 1 exit status

error: command 'i686-linux-gnu-gcc' failed with exit status 1 错误:命令'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

and in 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

So, I expect you to help me with this issue and gonna be very thankful:) 所以,我希望你能帮我解决这个问题,非常感谢:)

In setup.py string setup.py字符串中

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

replace by 替换为

if True:

Thanks to Thomas K 感谢Thomas K.

From cx_freeze/issues 来自cx_freeze / issues

Download 下载

You need to download the source code 您需要下载源代码

For python 3.3 and 3.4: 对于python 3.3和3.4:

  1. sudo apt-get install python3-dev

  2. sudo apt-get install libssl-dev

  3. Open setup.py and change the line 打开setup.py并更改该行

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

    to

    if True:

  4. python3 setup.py build

  5. sudo python3 setup.py install

For python 2.7: 对于python 2.7:

  1. sudo apt-get install python-dev

  2. sudo apt-get install libssl-dev

  3. Open setup.py and change the line 打开setup.py并更改该行

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

    to

    if True:

  4. python setup.py build

  5. sudo python setup.py install

GriMel's answer worked for me. GriMel的回答对我有用。 Until cx_freeze releases an update for this, I'm including a set of steps that you can do to get this working using GriMels' solution. 在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/

I've also opened up a bitbucket issue with what appears to be the source repo. 我还打开了一个似乎是源回购的bitbucket问题。

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

Looks like you might have a typo change 看起来你可能会有拼写错误

 sudo pip3 install cx-Freeze

to

 sudo pip3 install cx_Freeze

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

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