pythonpy2exesetup.pypysvn

Python - FileNotFoundError for pysvn in calling exe compiled with py2exe


setup.py for py2exe:

setup(console=['TagProject.py'], options={'py2exe':{'dist_dir':'AriesTools'} } )

When I called the exe, I got the error:

Traceback (most recent call last):
  File "TagProject.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "pysvn\__init__.pyc", line 116, in <module>
  File "os.pyc", line 1111, in add_dll_directory
FileNotFoundError: [WinError 3] The system cannot find the path specified: 
'H:\\PythonScripts\\AriesTools\\library.zip\\pysvn'

Installed components:

Python 3.9.6 (32-bit)
Python 3.9 PySVN 1.9.13-2056 on Win32
py2exe-0.10.4.0-cp39-cp39-win32.whl

I used the same process to create exe for other scripts which do not use pysvn, and the exe did not show the same problem.


Solution

  • I have solved the problem by removing the below statement in pysvn\__init__.py file:

    add_dll_handle = os.add_dll_directory( os.path.dirname( __file__ ) )
    

    The module pysvn still works fine without this statement. Hope someone figure out a better solution than this. For now, I am good with this.