0

I followed this topic answer to build .exe from python file,

hello.py

import sys

for arg in sys.argv:
    print(arg)
print("Hello World!")

And setup.py

from distutils.core import setup
import py2exe

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

I ran these commands:

python setup.py py2exe

   

*>  20 missing Modules
>       ------------------
>     ? IronPythonConsole                   imported from pyreadline.console.ironpython_console
>     ? System                              imported from pyreadline.console.ironpython_console,
> pyreadline.keysyms.ironpython_keysyms, pyreadline.rlmain
>     ? System.Windows.Forms.Clipboard      imported from pyreadline.clipboard.ironpython_clipboard
>     ? __main__                            imported from bdb, pdb
>     ? _frozen_importlib                   imported from importlib, importlib.abc, zipimport
>     ? _frozen_importlib_external          imported from importlib, importlib._bootstrap, importlib.abc, zipimport
>     ? _posixshmem                         imported from multiprocessing.resource_tracker, multiprocessing.shared_memory
>     ? _winreg                             imported from platform
>     ? asyncio.DefaultEventLoopPolicy      imported from -
>     ? dummy.Process                       imported from multiprocessing.pool
>     ? java.lang                           imported from platform
>     ? modes.editingmodes                  imported from pyreadline.rlmain
>     ? org.python.core                     imported from copy, pickle
>     ? os.path                             imported from ctypes._aix, distutils.file_util, os, pkgutil, py_compile, sysconfig, tracemalloc,
> unittest, unittest.util
>     ? pyreadline.keysyms.make_KeyPress    imported from pyreadline.console.ironpython_console
>     ? pyreadline.keysyms.make_KeyPress_from_keydescr imported from pyreadline.console.ironpython_console
>     ? pyreadline.keysyms.make_keyinfo     imported from pyreadline.console.ironpython_console
>     ? pyreadline.keysyms.make_keysym      imported from pyreadline.console.ironpython_console
>     ? resource                            imported from test.support
>     ? startup                             imported from pyreadline.keysyms.common, pyreadline.keysyms.keysyms
>     Building 'dist\hello.exe'.
>     Building shared code archive 'dist\library.zip'.
>     Traceback (most recent call last):
>       File "setup.py", line 4, in <module>
>         setup(console=['hello.py'])
>       File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup
>         dist.run_commands()
>       File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
>         self.run_command(cmd)
>       File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 985, in run_command
>         cmd_obj.run()
>       File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\distutils_buildexe.py",
> line 204, in run
>         self._run()
>       File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\distutils_buildexe.py",
> line 285, in _run
>         builder.build()
>       File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\runtime.py", line
> 273, in build
>         self.build_archive(libpath, delete_existing_resources=True)
>       File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\runtime.py", line
> 479, in build_archive
>         base = dist_path.rsplit('\\', 1)[0]
>     AttributeError: 'NoneType' object has no attribute 'rsplit'*

my python is 3.8.8, And then in the dist folder, I ran this:

hello.exe foo bar
>  Python path configuration:
>       PYTHONHOME = (not set)
>       PYTHONPATH = (not set)
>       program name = 'E:\exe_example\dist\hello.exe'
>       isolated = 1
>       environment = 0
>       user site = 0
>       import site = 0
>       sys._base_executable = 'E:\\exe_example\\dist\\hello.exe'
>       sys.base_prefix = ''
>       sys.base_exec_prefix = ''
>       sys.executable = 'E:\\exe_example\\dist\\hello.exe'
>       sys.prefix = ''
>       sys.exec_prefix = ''
>       sys.path = [
>         'E:\\exe_example\\dist\\library.zip',
>       ]
>     Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
>     Python runtime state: core initialized
>     ModuleNotFoundError: No module named 'encodings'
MattDMo
  • 100,794
  • 21
  • 241
  • 231

0 Answers0