yop
yop

Reputation: 31

how to make vpython .exe using pyinstaller

I have a simple script using vpython (just testing) and I want to create a .exe file with pyinstaller.

This is the script:

from visual import*
box()

Then I run in the console:

pyinstaller sss.py

But the .exe dont work(obviously)

I've been googling about how to make the .spec file for vpython but dont find nothing.

Also tried making this .spec file

# -*- mode: python -*-

block_cipher = None


a = Analysis(['sss.py'],
             pathex=['C:\\Users\\hdfh\\Documents\\Python Scripts'],
             binaries=None,
             datas=None,
             hiddenimports=(['visual','vis','visual_common','viddle']),
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='sss.exe',
          debug=False,
          strip=None,
          upx=True,
          console=False )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name='sss')

But it dindt work

Upvotes: 2

Views: 516

Answers (1)

yop
yop

Reputation: 31

I will reponse myself, maybe it helps someone.

When pyinstaller is used with vpython and you try to run the .exe file, it has problem for find the TGA archives placed in

C:\Anaconda2\Lib\site-packages\visual_common

So we have to edit the archive materials.py

C:\Anaconda2\Lib\site-packages\visual_common\materials.py

Here we look for the code

import sys
if hasattr(sys,'frozen') and (sys.frozen=="windows_exe" or sys.frozen=="console_exe"):
    texturePath="visual\\"
else:
    texturePath = os.path.split( __file__ )[0] + "/"
del sys

For me worked change texturePath=...to another directory, for example C:

import sys
if hasattr(sys,'frozen') and (sys.frozen=="windows_exe" or sys.frozen=="console_exe"):
    texturePath=os.path.abspath("C:/")
else:
    texturePath = os.path.abspath("C:/")
del sys

Save it and MOVE the TGA archives from visual_common to C:/ (or to the chosen place) and finally try to build the .exe from the console

pyinstaller test.py

For this works...

Upvotes: 1

Related Questions