visvis icon indicating copy to clipboard operation
visvis copied to clipboard

Freeze problem with PyInstaller

Open matejrazpotnik opened this issue 5 years ago • 5 comments

Trying to freeze a simple visvis script with PyInstaller results in the FileNotFoundError.

To reproduce the issue here is a minimal working example:

import visvis as vv

print("The library visvis has been imported.")

The build is successfully generated; however, running the exe from the command line produces the following output:

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\Users\ .....\test_visvis\dist\test_visvis\visvisResources' [3060] Failed to execute script test_visvis

I am using: Win10 Python 3.7 (tried with 3.6 and 3.5 as well and it ends up in the same error) Pyinstaller 3.4 visvis 1.11.2

matejrazpotnik avatar May 02 '19 07:05 matejrazpotnik

I just spend some time to improve support for PyInstaller. The idea is to make this simple hook work:

# hook-visvis.py
from visvis import freezeHelp
datas = freezeHelp.collectResourcePaths()

I did make some progress, but got stuck on the part where visvis dynamically loads functions, which are now in PyInstaller's internals somewhere. Certainly possible to make this work, but I have other priorities right now ...

almarklein avatar Oct 01 '19 09:10 almarklein

Hi Almar, do you have any updates on this? I implemented the hook and it worked, however during loading, I'm getting the following error:

File "visvis/processing/__init__.py", line 84, in <module> File "visvis/processing/__init__.py", line 49, in _insertFunctions File "zipfile.py", line 1225, in __init__ File "zipfile.py", line 1292, in _RealGetContents zipfile.BadZipFile: File is not a zip file

kdewald avatar Mar 29 '20 19:03 kdewald

I have not yet looked at it further.

almarklein avatar Mar 30 '20 07:03 almarklein

Hi, @kdewald, I had the same issue, I fixed the problem by two things:

  • hook looks like this:
# hook-visvis.py
from PyInstaller.utils.hooks import collect_all
from visvis import freezeHelp


datas, binaries, hiddenimports = collect_all('visvis')
datas.extend(freezeHelp.collectResourcePaths())
  • had to hack visvis in functions/__init__.py and processing/__init__.py, same change for both, just replaced condition in if with false:
    # if hasattr(sys, '_MEIPASS'):  # PyInstaller
    if False:
        zipfilename, path = sys.executable, ""

Probably not the best change, but it worked for me. I use Ubuntu 18.04.3 LTS, kernel 5.4.0-53-generic, 64-bit OS, Python 3.6, PyInstaller 4.1, visvis 1.12.4. Not sure what else is relevant...

Hope this information helps someone or @almarklein to add some hotfix to the project.

mrugala avatar Nov 28 '20 00:11 mrugala

@mrugala Thanks for your solutions

xflyyxfl avatar Feb 19 '21 06:02 xflyyxfl