Title: Why does my python exe file give an winerror 3 (missing modules py2exe)
Tags: python,py2exe,python-xmlschema

Question: Update:
I just tried to replicate my problem, and I found that there seems to be a problem when creating the exe file.
py2exe says that 98 modules are missing and one of these are what is causing my winerror. I cannot, however, find the solution to these missing modules.
    INFO:runtime:Analyzing the code
INFO:runtime:Found 622 modules, 98 are missing, 0 may be missing

  98 missing Modules
  ------------------
? __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 -
? converters.AbderaConverter          imported from xmlschema
? converters.BadgerFishConverter      imported from xmlschema
? converters.ColumnarConverter        imported from xmlschema
? converters.ElementData              imported from xmlschema, xmlschema.aliases, xmlschema.dataobjects, xmlschema.validators.elements, xmlschema.validators.groups
? converters.JsonMLConverter          imported from xmlschema
? converters.ParkerConverter          imported from xmlschema
? converters.UnorderedConverter       imported from xmlschema
? converters.XMLSchemaConverter       imported from xmlschema, xmlschema.aliases, xmlschema.dataobjects, xmlschema.validators.elements, xmlschema.validators.schemas
? cssselect                           imported from lxml.cssselect
? datatypes.AbstractBinary            imported from elementpath.serialization
? datatypes.AbstractDateTime          imported from elementpath.serialization, elementpath.xpath1._xpath1_operators, elementpath.xpath_tokens
? datatypes.AbstractQName             imported from elementpath.compare
? datatypes.AnyAtomicType             imported from elementpath.sequence_types, elementpath.serialization, elementpath.xpath_context, elementpath.xpath_tokens
? datatypes.AnyURI                    imported from elementpath.compare, elementpath.serialization, elementpath.xpath1._xpath1_functions, elementpath.xpath1._xpath1_operators, elementpath.xpath2._xpath2_functions, elementpath.xpath2._xpath2_operators, elementpath.xpath30._xpath30_functions, elementpath.xpath_tokens
? datatypes.ArithmeticProxy           imported from elementpath.xpath1._xpath1_operators, elementpath.xpath2._xpath2_functions
? datatypes.AtomicValueType           imported from elementpath.schema_proxy, elementpath.xpath2.xpath2_parser, elementpath.xpath_nodes, elementpath.xpath_tokens
? datatypes.Base64Binary              imported from elementpath.xpath2._xpath2_constructors
? datatypes.BooleanProxy              imported from elementpath.xpath2._xpath2_constructors
? datatypes.Date                      imported from elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions
? datatypes.Date10                    imported from elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath30._xpath30_functions, elementpath.xpath_tokens
? datatypes.DateTime                  imported from elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions
? datatypes.DateTime10                imported from elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath30._xpath30_functions, elementpath.xpath_tokens
? datatypes.DateTimeStamp             imported from elementpath.xpath2._xpath2_constructors
? datatypes.DayTimeDuration           imported from elementpath.xpath1._xpath1_functions, elementpath.xpath1._xpath1_operators, elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath_tokens
? datatypes.DoubleProxy               imported from elementpath.xpath2._xpath2_functions, elementpath.xpath_tokens
? datatypes.DoubleProxy10             imported from elementpath.xpath2._xpath2_operators, elementpath.xpath_tokens
? datatypes.Duration                  imported from elementpath.xpath1._xpath1_functions, elementpath.xpath1._xpath1_operators, elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath2._xpath2_operators, elementpath.xpath_tokens
? datatypes.Float10                   imported from elementpath.xpath1._xpath1_functions, elementpath.xpath2._xpath2_functions
? datatypes.GregorianDay              imported from elementpath.xpath2._xpath2_constructors
? datatypes.GregorianMonth            imported from elementpath.xpath2._xpath2_constructors
? datatypes.GregorianMonthDay         imported from elementpath.xpath2._xpath2_constructors
? datatypes.GregorianYear             imported from elementpath.xpath2._xpath2_constructors
? datatypes.GregorianYear10           imported from elementpath.xpath2._xpath2_constructors
? datatypes.GregorianYearMonth        imported from elementpath.xpath2._xpath2_constructors
? datatypes.GregorianYearMonth10      imported from elementpath.xpath2._xpath2_constructors
? datatypes.HexBinary                 imported from elementpath.xpath2._xpath2_constructors
? datatypes.Id                        imported from elementpath.xpath2._xpath2_functions
? datatypes.Integer                   imported from elementpath.xpath2._xpath2_operators, elementpath.xpath_tokens
? datatypes.Language                  imported from elementpath.xpath_context
? datatypes.NCName                    imported from elementpath.xpath2._xpath2_functions
? datatypes.NumericProxy              imported from elementpath.sequence_types, elementpath.xpath1._xpath1_operators, elementpath.xpath2._xpath2_functions, elementpath.xpath30._xpath30_functions
? datatypes.QName                     imported from elementpath.exceptions, elementpath.sequence_types, elementpath.serialization, elementpath.xpath1.xpath1_parser, elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath2._xpath2_operators, elementpath.xpath2.xpath2_parser, elementpath.xpath30._xpath30_functions, elementpath.xpath30._xpath30_operators, elementpath.xpath_tokens
? datatypes.StringProxy               imported from elementpath.xpath1._xpath1_functions
? datatypes.Time                      imported from elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath30._xpath30_functions
? datatypes.Timezone                  imported from elementpath.xpath_context, elementpath.xpath_tokens
? datatypes.UntypedAtomic             imported from elementpath.compare, elementpath.serialization, elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions, elementpath.xpath2._xpath2_operators, elementpath.xpath2.xpath2_parser, elementpath.xpath30._xpath30_functions, elementpath.xpath_nodes, elementpath.xpath_tokens
? datatypes.YearMonthDuration         imported from elementpath.xpath1._xpath1_functions, elementpath.xpath1._xpath1_operators, elementpath.xpath2._xpath2_constructors, elementpath.xpath2._xpath2_functions   
? datatypes.get_atomic_value          imported from elementpath.xpath2._xpath2_operators, elementpath.xpath_nodes
? datatypes.xsd10_atomic_types        imported from elementpath.sequence_types, elementpath.xpath2._xpath2_constructors, elementpath.xpath30._xpath30_functions, elementpath.xpath_tokens
? datatypes.xsd11_atomic_types        imported from elementpath.sequence_types, elementpath.xpath2._xpath2_constructors
? dummy.Process                       imported from multiprocessing.pool
? java.lang                           imported from platform
? org.python.core                     imported from copy, pickle
? os.path                             imported from ctypes._aix, distutils.file_util, elementpath.xpath2._xpath2_functions, os, pkgutil, py_compile, sysconfig, tracemalloc, unittest, unittest.util, xmlschema.resources
? readline                            imported from cmd, code, pdb
? regex.RegexError                    imported from elementpath, elementpath.xpath2._xpath2_functions, elementpath.xpath30._xpath30_functions
? regex.translate_pattern             imported from elementpath, elementpath.xpath2._xpath2_functions, elementpath.xpath30._xpath30_functions, elementpath.xpath30.xpath30_helpers
? resource                            imported from test.support
? urllib2                             imported from lxml.ElementInclude
? urlparse                            imported from lxml.ElementInclude
? validators.XMLSchema                imported from xmlschema
? validators.XMLSchema10              imported from xmlschema, xmlschema.documents
? validators.XMLSchema11              imported from xmlschema
? validators.XMLSchemaBase            imported from xmlschema, xmlschema.aliases, xmlschema.documents
? validators.XMLSchemaChildrenValidationError imported from xmlschema
? validators.XMLSchemaDecodeError     imported from xmlschema
? validators.XMLSchemaEncodeError     imported from xmlschema
? validators.XMLSchemaImportWarning   imported from xmlschema
? validators.XMLSchemaIncludeWarning  imported from xmlschema
? validators.XMLSchemaModelDepthError imported from xmlschema
? validators.XMLSchemaModelError      imported from xmlschema
? validators.XMLSchemaNotBuiltError   imported from xmlschema, xmlschema.xpath
? validators.XMLSchemaParseError      imported from xmlschema
? validators.XMLSchemaTypeTableWarning imported from xmlschema
? validators.XMLSchemaValidationError imported from xmlschema, xmlschema.aliases, xmlschema.dataobjects, xmlschema.documents
? validators.XMLSchemaValidatorError  imported from xmlschema
? validators.XsdAnyAttribute          imported from xmlschema.aliases
? validators.XsdAnyElement            imported from xmlschema.aliases
? validators.XsdAssert                imported from xmlschema.aliases
? validators.XsdAttribute             imported from xmlschema, xmlschema.aliases
? validators.XsdAttributeGroup        imported from xmlschema.aliases
? validators.XsdComplexType           imported from xmlschema.aliases
? validators.XsdComponent             imported from xmlschema, xmlschema.aliases
? validators.XsdElement               imported from xmlschema, xmlschema.aliases, xmlschema.converters.abdera, xmlschema.converters.badgerfish, xmlschema.converters.columnar, xmlschema.converters.default, xmlschema.converters.jsonml, xmlschema.converters.parker, xmlschema.converters.unordered, xmlschema.dataobjects
? validators.XsdGlobals               imported from xmlschema
? validators.XsdGroup                 imported from xmlschema.aliases
? validators.XsdNotation              imported from xmlschema.aliases
? validators.XsdSimpleType            imported from xmlschema.aliases
? validators.XsdType                  imported from xmlschema
? xpath1.XPath1Parser                 imported from elementpath, elementpath.sequence_types, elementpath.xpath2.xpath2_parser, elementpath.xpath_selectors, elementpath.xpath_tokens
? xpath2.XPath2Parser                 imported from elementpath, elementpath.schema_proxy, elementpath.xpath30.xpath30_parser, elementpath.xpath_selectors, elementpath.xpath_tokens
? xpath30.XPath30Parser               imported from elementpath.schema_proxy, elementpath.xpath_selectors, elementpath.xpath_tokens
Building 'dist\xml_validator.exe'.

I just created a python exe file with py2exe, in the script I use the library xmlschema.
The exe was created correct, as far as i can see, freeze script used:
from py2exe import freeze

freeze(    
    windows=["xml_validator.py"],
    options={
        "includes": ["sys", "os"],
        "packages": ["xmlschema", "lxml", "tkinter"]
    },
    version_info= {
        "version": "1.0",
        "description": "A xml validator for incomming files"
    }
)


but when I run the program I get this error .log file
Traceback (most recent call last):
  File "urllib\request.pyc", line 1505, in open_local_file
FileNotFoundError: [WinError 3] Den angivne sti blev ikke fundet: 'C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "xml_validator.py", line 4, in <module>
  File "xmlschema\__init__.pyc", line 21, in <module>
  File "xmlschema\dataobjects.pyc", line 24, in <module>
  File "xmlschema\validators\__init__.pyc", line 38, in <module>
  File "xmlschema\validators\schemas.pyc", line 2183, in <module>
  File "xmlschema\validators\schemas.pyc", line 134, in __new__
  File "xmlschema\validators\schemas.pyc", line 768, in create_meta_schema
  File "xmlschema\validators\schemas.pyc", line 345, in __init__
  File "xmlschema\resources.pyc", line 482, in __init__
  File "xmlschema\resources.pyc", line 743, in parse
  File "urllib\request.pyc", line 216, in urlopen
  File "urllib\request.pyc", line 519, in open
  File "urllib\request.pyc", line 536, in _open
  File "urllib\request.pyc", line 496, in _call_chain
  File "urllib\request.pyc", line 1483, in file_open
  File "urllib\request.pyc", line 1522, in open_local_file
urllib.error.URLError: <urlopen error [WinError 3] Den angivne sti blev ikke fundet: 'C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'>
Traceback (most recent call last):
  File "urllib\request.pyc", line 1505, in open_local_file
FileNotFoundError: [WinError 3] Den angivne sti blev ikke fundet: 'C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "xml_validator.py", line 4, in <module>
  File "xmlschema\__init__.pyc", line 21, in <module>
  File "xmlschema\dataobjects.pyc", line 24, in <module>
  File "xmlschema\validators\__init__.pyc", line 38, in <module>
  File "xmlschema\validators\schemas.pyc", line 2183, in <module>
  File "xmlschema\validators\schemas.pyc", line 134, in __new__
  File "xmlschema\validators\schemas.pyc", line 768, in create_meta_schema
  File "xmlschema\validators\schemas.pyc", line 345, in __init__
  File "xmlschema\resources.pyc", line 482, in __init__
  File "xmlschema\resources.pyc", line 743, in parse
  File "urllib\request.pyc", line 216, in urlopen
  File "urllib\request.pyc", line 519, in open
  File "urllib\request.pyc", line 536, in _open
  File "urllib\request.pyc", line 496, in _call_chain
  File "urllib\request.pyc", line 1483, in file_open
  File "urllib\request.pyc", line 1522, in open_local_file
urllib.error.URLError: <urlopen error [WinError 3] Den angivne sti blev ikke fundet: 'C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'>
Traceback (most recent call last):
  File "urllib\request.pyc", line 1505, in open_local_file
FileNotFoundError: [WinError 3] Den angivne sti blev ikke fundet: 'C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "xml_validator.py", line 4, in <module>
  File "xmlschema\__init__.pyc", line 21, in <module>
  File "xmlschema\dataobjects.pyc", line 24, in <module>
  File "xmlschema\validators\__init__.pyc", line 38, in <module>
  File "xmlschema\validators\schemas.pyc", line 2183, in <module>
  File "xmlschema\validators\schemas.pyc", line 134, in __new__
  File "xmlschema\validators\schemas.pyc", line 768, in create_meta_schema
  File "xmlschema\validators\schemas.pyc", line 345, in __init__
  File "xmlschema\resources.pyc", line 482, in __init__
  File "xmlschema\resources.pyc", line 743, in parse
  File "urllib\request.pyc", line 216, in urlopen
  File "urllib\request.pyc", line 519, in open
  File "urllib\request.pyc", line 536, in _open
  File "urllib\request.pyc", line 496, in _call_chain
  File "urllib\request.pyc", line 1483, in file_open
  File "urllib\request.pyc", line 1522, in open_local_file
urllib.error.URLError: <urlopen error [WinError 3] Den angivne sti blev ikke fundet: 'C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'>


When i look in the folder it is correct that this file does not exits, but why does it look for a file here?
it seems to me it is looking for a part of the library that is not there.

Answer: I'm pretty sure it is caused by a malformation of the path.
As you can see, it is trying to search for C:\\Users\\fmk\\OneDrive - Fors A S\\Dokumenter\\XML validator\\Python\\dist\\library.zip\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd
The folder OneDrive - Fors A S has some spaces in the name, which should be escaped with either a surrounding of "" or \ before the spaces. I can't see the code snippet where you declare the path, but you could try giving a simple path, just to try. If this is the problem, then you can leverage some Python libraries to get a sanified relative path
If you don't declare any path, then you should check the documentation to see if it is possible to specify a new path or try to launch this script somewhere else