如何使用pyinstaller制作vpython .exe [英] how to make vpython .exe using pyinstaller

查看:121
本文介绍了如何使用pyinstaller制作vpython .exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用vpython的简单脚本(只是测试),我想用pyinstaller创建一个.exe文件.

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

这是脚本:

from visual import*
box()

然后我在控制台中运行:

Then I run in the console:

pyinstaller sss.py

但是.exe不起作用(显然)

But the .exe dont work(obviously)

我一直在搜寻如何为vpython制作.spec文件,但一无所获.

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

还尝试制作此.spec文件

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')

但这没用

推荐答案

我会做出回应,也许会对某人有所帮助.

I will reponse myself, maybe it helps someone.

当pyinstaller与vpython一起使用时,如果您尝试运行.exe文件,则无法找到放置在

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

所以我们必须编辑存档材料.py

So we have to edit the archive materials.py

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

我们在这里寻找代码

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

对我来说,将texturePath=...更改为另一个目录,例如C:

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

保存并将TGA存档从visual_common移至C:/(或所选位置),最后尝试从控制台构建.exe

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

为此有效...

这篇关于如何使用pyinstaller制作vpython .exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆