New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

future does not work with py2exe and cx_Freeze #31

Closed
geerk opened this Issue Jan 25, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@geerk

geerk commented Jan 25, 2014

I've tried to use py2exe to generate executable for windows.

hello.py:

# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)
from future import standard_library
from future.builtins import *

print("Hello World!")

setup.py:

from distutils.core import setup
import py2exe

setup(console=['hello.py'])

run py2exe:

C:\Users\User\hello>C:\Python27\python.exe setup.py py2exe
...
*** copy extensions ***
*** copy dlls ***
copying C:\Python27\lib\site-packages\py2exe\run.exe -> C:\Users\User\hello\dist
\hello.exe
The following modules appear to be missing
['builtins']

*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.

Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.

   USER32.dll - C:\Windows\system32\USER32.dll
   SHELL32.dll - C:\Windows\system32\SHELL32.dll
   ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
   WS2_32.dll - C:\Windows\system32\WS2_32.dll
   GDI32.dll - C:\Windows\system32\GDI32.dll
   KERNEL32.dll - C:\Windows\system32\KERNEL32.dll

then try to execute:

C:\Users\User\hello>cd dist

C:\Users\User\hello\dist>hello.exe
Traceback (most recent call last):
  File "hello.py", line 4, in <module>
  File "future\standard_library\__init__.pyc", line 449, in <module>
  File "future\standard_library\__init__.pyc", line 381, in install_hooks
ImportError: No module named UserList
@edschofield

This comment has been minimized.

Show comment
Hide comment
@edschofield

edschofield Jan 28, 2014

Contributor

@geerk: thanks for reporting this.

What happens when you type this?

C:\Users\User\hello>C:\Python27\python.exe
>>> import UserList

You may need to pass a list like ['future', 'future.builtins'] as the packages keyword argument to setup.py. See future's setup.py for an example.

Contributor

edschofield commented Jan 28, 2014

@geerk: thanks for reporting this.

What happens when you type this?

C:\Users\User\hello>C:\Python27\python.exe
>>> import UserList

You may need to pass a list like ['future', 'future.builtins'] as the packages keyword argument to setup.py. See future's setup.py for an example.

@geerk

This comment has been minimized.

Show comment
Hide comment
@geerk

geerk Jan 29, 2014

importing UserList successfull:

C:\Users\User\hello>C:\Python27\python.exe
>>> import UserList
>>>

but with packages ['future', 'future.builtins'] a got:

C:\Users\User\hello>C:\Python27\python.exe setup.py py2exe
running py2exe
running build_py
error: package directory 'future' does not exist

setup.py:

from distutils.core import setup
import py2exe

setup(console=['hello.py'], packages=['future', 'future.builtins'])

geerk commented Jan 29, 2014

importing UserList successfull:

C:\Users\User\hello>C:\Python27\python.exe
>>> import UserList
>>>

but with packages ['future', 'future.builtins'] a got:

C:\Users\User\hello>C:\Python27\python.exe setup.py py2exe
running py2exe
running build_py
error: package directory 'future' does not exist

setup.py:

from distutils.core import setup
import py2exe

setup(console=['hello.py'], packages=['future', 'future.builtins'])
@geerk

This comment has been minimized.

Show comment
Hide comment
@geerk

geerk Jan 30, 2014

I tried to get executable with cx_freeze, but no luck. I started with automatically generated setup.py:

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

base = 'Console'

executables = [
    Executable('hello.py', base=base)
]

setup(name='hello',
      version = '1.0',
      description = '',
      options = dict(build_exe = buildOptions),
      executables = executables)

then build it with C:\Python27\python.exe setup.py build, got an executable, but when I tried to run it I got following error:

C:\Users\User\hello\build\exe.win32-2.7>hello.exe
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
    exec code in m.__dict__
  File "hello.py", line 4, in <module>
  File "C:\Python27\lib\site-packages\future-0.10.2-py2.7.egg\future\standard_li
brary\__init__.py", line 449, in <module>
    install_hooks()
  File "C:\Python27\lib\site-packages\future-0.10.2-py2.7.egg\future\standard_li
brary\__init__.py", line 381, in install_hooks
    oldmod = __import__(oldmodname)
ImportError: No module named UserList

Then I tried to add packages=['future', 'future.builtins'], but when I tried to built it I got following error:

C:\Users\User\hello>C:\Python27\python.exe setup.py build
running build
running build_exe
copying C:\Python27\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.w
in32-2.7\hello.exe
copying C:\Windows\system32\python27.dll -> build\exe.win32-2.7\python27.dll
*** WARNING *** unable to create version resource
install pywin32 extensions first
Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    executables = executables)
  File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 365, in setup
    distutils.core.setup(**attrs)
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 235, in run
    freezer.Freeze()
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 582, in Freeze

    self.compress, self.copyDependentFiles)
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 492, in _Write
Modules
    module.Create(finder)
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 714, in Create

    module.file, module.name)
cx_Freeze.freezer.ConfigError: no file named sys (for module collections.sys)

I also tried packages=['future', 'future.builtins', 'future.standard_library'], but got the same error.

geerk commented Jan 30, 2014

I tried to get executable with cx_freeze, but no luck. I started with automatically generated setup.py:

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])

base = 'Console'

executables = [
    Executable('hello.py', base=base)
]

setup(name='hello',
      version = '1.0',
      description = '',
      options = dict(build_exe = buildOptions),
      executables = executables)

then build it with C:\Python27\python.exe setup.py build, got an executable, but when I tried to run it I got following error:

C:\Users\User\hello\build\exe.win32-2.7>hello.exe
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
    exec code in m.__dict__
  File "hello.py", line 4, in <module>
  File "C:\Python27\lib\site-packages\future-0.10.2-py2.7.egg\future\standard_li
brary\__init__.py", line 449, in <module>
    install_hooks()
  File "C:\Python27\lib\site-packages\future-0.10.2-py2.7.egg\future\standard_li
brary\__init__.py", line 381, in install_hooks
    oldmod = __import__(oldmodname)
ImportError: No module named UserList

Then I tried to add packages=['future', 'future.builtins'], but when I tried to built it I got following error:

C:\Users\User\hello>C:\Python27\python.exe setup.py build
running build
running build_exe
copying C:\Python27\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.w
in32-2.7\hello.exe
copying C:\Windows\system32\python27.dll -> build\exe.win32-2.7\python27.dll
*** WARNING *** unable to create version resource
install pywin32 extensions first
Traceback (most recent call last):
  File "setup.py", line 17, in <module>
    executables = executables)
  File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 365, in setup
    distutils.core.setup(**attrs)
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\site-packages\cx_Freeze\dist.py", line 235, in run
    freezer.Freeze()
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 582, in Freeze

    self.compress, self.copyDependentFiles)
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 492, in _Write
Modules
    module.Create(finder)
  File "C:\Python27\lib\site-packages\cx_Freeze\freezer.py", line 714, in Create

    module.file, module.name)
cx_Freeze.freezer.ConfigError: no file named sys (for module collections.sys)

I also tried packages=['future', 'future.builtins', 'future.standard_library'], but got the same error.

@edschofield

This comment has been minimized.

Show comment
Hide comment
@edschofield

edschofield Jan 30, 2014

Contributor

Thanks for the report.

Try commenting out the install_hooks() line in future\standard_library\__init__.py. Then you should be able to use future with py2exe and cx_freeze minus the standard_library feature.

Auto-installation of import hooks by future\standard_library\__init__.py will be removed in version 0.12 of future: see http://python-future.org/whatsnew.html#deprecated-feature-auto-installation-of-standard-library-import-hooks.

(By the way, v0.11.2 is now on PyPI but you'd need the same trick with that.)

Contributor

edschofield commented Jan 30, 2014

Thanks for the report.

Try commenting out the install_hooks() line in future\standard_library\__init__.py. Then you should be able to use future with py2exe and cx_freeze minus the standard_library feature.

Auto-installation of import hooks by future\standard_library\__init__.py will be removed in version 0.12 of future: see http://python-future.org/whatsnew.html#deprecated-feature-auto-installation-of-standard-library-import-hooks.

(By the way, v0.11.2 is now on PyPI but you'd need the same trick with that.)

@geerk

This comment has been minimized.

Show comment
Hide comment
@geerk

geerk Feb 1, 2014

Thanks, it works with v0.11.2 but without standard library.

geerk commented Feb 1, 2014

Thanks, it works with v0.11.2 but without standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment