Compile Web2Py in .exe with CX_Freeze

1

Dear, I have a problem, I want to convert the app created in Web2Py in an .exe app, but when I run cx-freeze it tells me this error:

    Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    from cx_Freeze import setup, Executable
  File "C:\Python27\lib\site-packages\cx_Freeze\__init__.py", line 11, in <modul
e>
    from cx_Freeze.freezer import *
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 13, in <module
>
    import socket
  File "C:\Python27\lib\socket.py", line 47, in <module>
    import _socket
ImportError: DLL load failed: No se encontr¾ el proceso especificado.

I think it's because I'm trying to compile another .exe, which is Web2Py, now I pass the script setup.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Usage:
    Install cx_Freeze: http://cx-freeze.sourceforge.net/
    Copy script to the web2py directory
    c:\Python27\python standalone_exe_cxfreeze.py build_exe
"""
from cx_Freeze import setup, Executable
from gluon.import_all import base_modules, contributed_modules
from gluon.fileutils import readlines_file
from glob import glob
import fnmatch
import os
import shutil
import sys
import re

#read web2py version from VERSION file
web2py_version_line = readlines_file('VERSION')[0]
#use regular expression to get just the version number
v_re = re.compile('[0-9]+\.[0-9]+\.[0-9]+')
web2py_version = v_re.search(web2py_version_line).group(0)

base = None



if sys.platform == 'win32':
    base = "Win32GUI"

base_modules.remove('macpath')
buildOptions = dict(
    compressed=True,
    excludes=["macpath", "PyQt4"],
    includes=base_modules,
    include_files=[
        'applications',
        'ABOUT',
        'LICENSE',
        'VERSION',
        'logging.example.conf',
        'options_std.py',
        'app.example.yaml',
        'queue.example.yaml',
    ],
    # append any extra module by extending the list below -
    # "contributed_modules+["lxml"]"
    packages=contributed_modules,
)

setup(
    name="Web2py",
    version=web2py_version,
    author="Massimo DiPierro",
    description="web2py web framework",
    license="LGPL v3",
    options=dict(build_exe=buildOptions),
    executables=[Executable("web2py.py",
                            base=base,
                            compress=True,
                            icon="web2py.ico",
                            targetName="web2py.exe",
                            copyDependentFiles=True)],
)

I do not realize if there is any way to compile binary or convert the app created with web2py to .exe.

    
asked by Nahuel Jakobson 10.05.2017 в 15:09
source

2 answers

1

The problem seems to be that CX_freeze could not find the dll _socket.pyd , this could be due to several reasons:

  • Some installation issue
  • Some problem product of mixing 64-bit / 32-bit installations

In either case, I would try to reinstall Python. The other "rustic" alternative is to set the search path to the folder where _socket.pyd is found

import sys
sys.path.append("Path a _socket.pyd")
import socket
    
answered by 10.05.2017 в 15:34
0

Here is the solution and several examples: link link

In the web2py google group they have a more active community that will solve your doubts faster, greetings.

    
answered by 30.05.2017 в 12:12