pyinstaller issue with vpython

500 views
Skip to first unread message

Rick Shaffer

unread,
Mar 1, 2021, 4:54:53 PM3/1/21
to VPython-users

 I have an issue with pyinstaller and/or vpython. I’ve tried to boil this down into the simplest code possible. Here is my python code:

import time
from vpython import *

def test2():

    while True:
        print ("Hello")
        time.sleep(2)

if __name__ == "__main__":
    test2()

When executing in the Anaconda/Spyder environment everything works as expected. However, after building a .exe with pyinstaller and executing test2.exe it fails with the following error :

Traceback (most recent call last):
File "test2.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "vpython\__init__.py", line 4, in <module>
File "vpython\gs_version.py", line 24, in glowscript_version
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Rick.PC-0XFZ\\Projects\\test2\\dist\\test2\\vpython\\vpython_libraries\\glow.min.js'
[8568] Failed to execute script test2

When I look at the path “C:\\Users\\Rick.PC-0XFZ\\Projects\\test2\\dist\\test2\\vpython\\vpython” I see “cyvector.cp38-win_amd64.pyd”, but no other files or directories. Specifically there is no “gs_version.py” file and no “vpython_libraries” directory.

Unfortunately I don’t know enough about .pyd files to understand the issue. And I’ve tried adding these directories to my sys.path but to no avail. Any suggestion or help is appreciated.

Thanks.

Bruce Sherwood

unread,
Mar 1, 2021, 9:38:52 PM3/1/21
to VPython-users
I know nothing about pyinstaller, but I'll comment that the vpython module most definitely does need all of the files that are in Lib/site-packages/vpython. I suppose however that (again, knowing nothing about pyinstaller) it's possible that the single pyd file does contain all of the pieces, and that something else is wrong. A very crude thing you might try is to compare the size of the vpython module and the size of the pyd file.

Bruce

Rick Shaffer

unread,
Mar 4, 2021, 12:38:58 PM3/4/21
to VPython-users
Bruce, thank you for the response. After a bit more finagling I did find a solution. Apparently pyinstaller is not aware of the need for the files in the vpython_libraries and vpython_data directories. So I simply added these files to the pyinstaller distribution with the "--add-data" option. Thanks again for your help.

Santiago Valencia Morales

unread,
Dec 19, 2021, 6:12:23 PM12/19/21
to VPython-users
Hi Rick, I have the same problem and I do not know how to solve it. Can you be more specific with the solution you found, please?

Prasanta Das

unread,
Oct 15, 2022, 12:14:09 PM10/15/22
to VPython-users
Hi Rick, I am stuck here. can you give the detail how to use --add-data command.
Reply all
Reply to author
Forward
0 new messages