I'm new to xmlschema and pyinstaller and need some help for the error that I have encountered.
I have downloaded both xmlschema (1.9)and pyinstaller (4.7) in Python 3.6.8. In my python script, I have added import xmlschema in order to use it. After that, I complied my code using `pyinstaller --onefile --windowed schema_check_xsd_11.py to create an windows exe application.
Compilation OK:
D:\Project\WA_Schema\Schema_Check>pyinstaller --onefile --windowed schema_check_xsd_11.py
82 INFO: PyInstaller: 4.7
82 INFO: Python: 3.6.8
84 INFO: Platform: Windows-10-10.0.17763-SP0
90 INFO: wrote D:\Project\WA_Schema\Schema_Check\schema_check_xsd_11.spec
92 INFO: UPX is not available.
93 INFO: Extending PYTHONPATH with paths
['D:\\Project\\WA_Schema\\Schema_Check']
346 INFO: checking Analysis
361 INFO: Building because D:\Project\WA_Schema\Schema_Check\schema_check_xsd_11.py changed
362 INFO: Initializing module dependency graph...
364 INFO: Caching module graph hooks...
380 INFO: Analyzing base_library.zip ...
2806 INFO: Caching module dependency graph...
2939 INFO: running Analysis Analysis-00.toc
2941 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python36\python.exe
3006 INFO: Analyzing D:\Project\WA_Schema\Schema_Check\schema_check_xsd_11.py
4478 INFO: Processing module hooks...
4479 INFO: Loading module hook 'hook-difflib.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4481 INFO: Loading module hook 'hook-encodings.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4621 INFO: Loading module hook 'hook-heapq.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4622 INFO: Loading module hook 'hook-pickle.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4624 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4628 INFO: Loading module hook 'hook-xml.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4675 INFO: Looking for ctypes DLLs
4676 INFO: Analyzing run-time hooks ...
4678 INFO: Including run-time hook 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
4683 INFO: Including run-time hook 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
4689 INFO: Looking for dynamic libraries
4806 INFO: Looking for eggs
4806 INFO: Using Python library c:\python36\python36.dll
4807 INFO: Found binding redirects:
[]
4815 INFO: Warnings written to D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\warn-schema_check_xsd_11.txt
4855 INFO: Graph cross-reference written to D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\xref-schema_check_xsd_11.html
4862 INFO: checking PYZ
4878 INFO: Building because toc changed
4878 INFO: Building PYZ (ZlibArchive) D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\PYZ-00.pyz
5355 INFO: Building PYZ (ZlibArchive) D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\PYZ-00.pyz completed successfully.
5366 INFO: checking PKG
5379 INFO: Building because toc changed
5380 INFO: Building PKG (CArchive) schema_check_xsd_11.pkg
6725 INFO: Building PKG (CArchive) schema_check_xsd_11.pkg completed successfully.
6727 INFO: Bootloader c:\python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
6727 INFO: checking EXE
6746 INFO: Building because toc changed
6747 INFO: Building EXE from EXE-00.toc
6758 INFO: Copying bootloader EXE to D:\Project\WA_Schema\Schema_Check\dist\schema_check_xsd_11.exe
6763 INFO: Copying icon to EXE
6764 INFO: Copying icons from ['c:\\python36\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
6769 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
6769 INFO: Writing RT_ICON 1 resource with 3752 bytes
6773 INFO: Writing RT_ICON 2 resource with 2216 bytes
6774 INFO: Writing RT_ICON 3 resource with 1384 bytes
6774 INFO: Writing RT_ICON 4 resource with 38188 bytes
6775 INFO: Writing RT_ICON 5 resource with 9640 bytes
6775 INFO: Writing RT_ICON 6 resource with 4264 bytes
6776 INFO: Writing RT_ICON 7 resource with 1128 bytes
6779 INFO: Copying 0 resources to EXE
6783 INFO: Emedding manifest in EXE
6784 INFO: Updating manifest in D:\Project\WA_Schema\Schema_Check\dist\schema_check_xsd_11.exe
6787 INFO: Updating resource type 24 name 1 language 0
6790 INFO: Appending PKG archive to EXE
8145 INFO: Building EXE from EXE-00.toc completed successfully.
Error when run windows application (schema_check_xsd_11.exe):
Traceback (most recent call last):
File "urllib\request.py", line 1474, in open_local_file
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\test\\AppData\\Local\\Temp\\_MEI169402\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "schema_check_xsd_11.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\__init__.py", line 20, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\dataobjects.py", line 27, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\validators\__init__.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\validators\schemas.py", line 2126, in <module>
File "xmlschema\validators\schemas.py", line 148, in __new__
File "xmlschema\validators\schemas.py", line 764, in create_meta_schema
File "xmlschema\validators\schemas.py", line 357, in __init__
File "xmlschema\resources.py", line 508, in __init__
File "xmlschema\resources.py", line 742, in parse
File "urllib\request.py", line 223, in urlopen
File "urllib\request.py", line 526, in open
File "urllib\request.py", line 544, in _open
File "urllib\request.py", line 504, in _call_chain
File "urllib\request.py", line 1452, in file_open
File "urllib\request.py", line 1491, in open_local_file
urllib.error.URLError: <urlopen error [WinError 3] The system cannot find the path specified: 'C:\\Users\\test\\AppData\\Local\\Temp\\_MEI169402\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'>
If I remove import xmlschema from my code and re-build, I can run the window application without any error. Appreciate for any advise or help. The installed xmlschema is located in C:\Python36\Lib\site-packages\xmlschema\schemas\XSD_1.0.
Just add --add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\XSD_1.0;xmlschema/schemas/XSD_1.0
to your PyInstaller command.