PyInstaller executable with panda3d throws exception - python

I am having an issue with a program, which uses panda3d. It works perfectly when executed as a pythonscript, but the version, which is compiled (or rather packaged) by PyInstaller throws the exception below.
:display(warning): Unable to load libpandagl.so: No error.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
File "Shipsim3d_1-1.py", line 930, in <module>
File "Shipsim3d_1-1.py", line 23, in __init__
File "direct/showbase/ShowBase.py", line 339, in __init__
File "direct/showbase/ShowBase.py", line 1024, in openDefaultWindow
File "direct/showbase/ShowBase.py", line 1059, in openMainWindow
File "direct/showbase/ShowBase.py", line 769, in openWindow
File "direct/showbase/ShowBase.py", line 749, in <lambda>
File "direct/showbase/ShowBase.py", line 821, in _doOpenWindow
File "direct/showbase/ShowBase.py", line 650, in makeDefaultPipe
File "direct/directnotify/Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.
[5466] Failed to execute script 'Shipsim3d_1-1' due to unhandled exception!
The .prc file doesn't exist in the executable, but even if I copy it there manually, it still doesn't work. In my Code, I use a function called loadPrcData. Is that a Part of the problem? Or is it something else?
Thanks in advance

Related

PyInstaller executable not working with panda3d. No graphics pipe availabe

I am having an issue with a program, which uses panda3d. It works perfectly when executed as a pythonscript, but the version, which is compiled (or rather packaged) by PyInstaller throws the exception below.
:display(warning): Unable to load libpandagl.so: No error.
Known pipe types:
(all display modules loaded.)
Traceback (most recent call last):
File "Shipsim3d_1-1.py", line 930, in <module>
File "Shipsim3d_1-1.py", line 23, in __init__
File "direct/showbase/ShowBase.py", line 339, in __init__
File "direct/showbase/ShowBase.py", line 1024, in openDefaultWindow
File "direct/showbase/ShowBase.py", line 1059, in openMainWindow
File "direct/showbase/ShowBase.py", line 769, in openWindow
File "direct/showbase/ShowBase.py", line 749, in <lambda>
File "direct/showbase/ShowBase.py", line 821, in _doOpenWindow
File "direct/showbase/ShowBase.py", line 650, in makeDefaultPipe
File "direct/directnotify/Notifier.py", line 130, in error
Exception: No graphics pipe is available!
Your Config.prc file must name at least one valid panda display
library via load-display or aux-display.
[5466] Failed to execute script 'Shipsim3d_1-1' due to unhandled exception!
Usually, there is a Config.prc file in the etc subdirectory of the panda3d site-package directory. This file is non-existent in the packaged version. But if I create this subdirectory there, and copy the files to it as well, it still doesn't work and it still throws the same exception. There is a line "loadPrcData("win-size 1080 1920")" in my main program as well. Could this be part of the problem in any way? Or is there something else i am missing?
Thanks in advance
I solved this problem by including the whole panda3d lib:
pyinstaller --add-data="path/to/panda3d;panda3d" -wF main.py

macOS python command line stopped working. cannot pickle '_thread._local'

I updated macOS recently and "/usr/local/bin/rethinkdb restore" now no longer works..
/usr/local/bin/rethinkdb restore --force /Users/rob/rdb_backup.tar.gz
Extracting archive file...
Done (0 seconds)
Importing from directory...
Traceback (most recent call last):
File "/usr/local/bin/rethinkdb-restore", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/rethinkdb/_restore.py", line 339, in main
do_restore(options)
File "/usr/local/lib/python3.9/site-packages/rethinkdb/_restore.py", line 315, in do_restore
_import.import_tables(options, sources)
File "/usr/local/lib/python3.9/site-packages/rethinkdb/_import.py", line 1359, in import_tables
progress_bar.start()
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 284, in _Popen
return Popen(process_obj)
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch
reduction.dump(process_obj, fp)
File "/usr/local/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_thread._local' object
I've refreshed my python install via brew, but that didn't help.
I don't use python myself, so I'm not familiar with fixing issues with it.
Any help would be appreciated.
Update: after much searching I found many people with the same issue and the consensus was the python code bundled with rethinkdb was broken and no longer supported. A couple of people offered nodejs replacements for the restore functionality. I was unable to get either working, probably due to dependencies.
The solution I read about that proved successful was to downgrade to python 3.7.9

Pyinstaller "FileNotFoundError: [Errno 2] No such file or directory:" when running app

I recently have packaged a python app using the pyinstaller --onefile command. It succesfully makes a executable file that launches fine. I can use pretty much almost all the functions in my script with no problem, except one. When I call a function of another python file (which is in my app folder), I get this error:
Traceback (most recent call last):
File "socketserver.py", line 647, in process_request_thread
File "socketserver.py", line 357, in finish_request
File "socketserver.py", line 717, in __init__
File "http/server.py", line 426, in handle
File "http/server.py", line 414, in handle_one_request
File "CaptchaHarvester/harvester/server/__init__.py", line 134, in do_GET
File "CaptchaHarvester/harvester/server/__init__.py", line 178, in handel_request
File "CaptchaHarvester/harvester/server/__init__.py", line 85, in _load_template
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/rl/rmr5s0ld22j0h_z15m90v0c80000gr/T/_MEIBVnHEv/harvester/server/templates/ga.chunk.html'
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 54955)
Traceback (most recent call last):
File "socketserver.py", line 647, in process_request_thread
File "socketserver.py", line 357, in finish_request
File "socketserver.py", line 717, in __init__
File "http/server.py", line 426, in handle
File "http/server.py", line 414, in handle_one_request
File "CaptchaHarvester/harvester/server/__init__.py", line 122, in do_GET
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/rl/rmr5s0ld22j0h_z15m90v0c80000gr/T/_MEIBVnHEv/harvester/server/icon.png'
The problem seems to be that pyinstaller cant properly find the files(icon.png and ga.hunk.html). These files are in a folder that is in the same folder as my main.py file. I was wondering how I can make pyinstaller find these files succesfully? I have tried to add to the datas class in the .spec file, but I still get the error. This is what that line looks like:datas=[('/Users/A/Desktop/ss/CaptchaHarvester/harvester/server/icon.png','/Users/A/Desktop/ss/CaptchaHarvester/harvester/server')],
Please let me know if I am doing something wrong or if yall have any ideas on how to resolve it.
I am on macosx catalina and python 3.7 if that is any help.
Thanks!
You can use arguments in command prompt to ensure the correct filesare found by pyinstaller; --add-data "path_to_file:path_in_executable in directory" an example would be
pyinstaller --add-data "icon.png;." --onefile socketserver.py
here icon.png is in the same directoy of socketserver.py and is copied to the root directory of the executable (the . signifies root directory)

TypeError: expected str, bytes or os.PathLike object, not NoneType _ while using pyinstaller

I wrote 3 python scripts and all of them are working fine when I run them with python3.6. Now I wanted to build executable files for each of these scripts using pyinstaller. Please Note that I cannot install pyinstaller on the computer due to the rules in my institution, so I downloaded the pyinstaller package and run the pyinstaller.py with python3.6 from the directory and it works fine.
The problem which I'm facing right now is the following:
Building the .exe works for one script without problems, but if I try to build the other 2 scripts I get the following error :
Traceback (most recent call last):
File "pyinstaller.py", line 15, in <module>
run()
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/__main__.py", line 94, in run
run_build(pyi_config, spec_file, **vars(args))
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/build_main.py", line 791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/build_main.py", line 737, in build
exec(text, spec_namespace)
File "<string>", line 22, in <module>
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/build_main.py", line 213, in __init__
self.__postinit__()
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/datastruct.py", line 161, in __postinit__
self.assemble()
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/build_main.py", line 472, in assemble
module_hook.post_graph()
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/imphook.py", line 414, in post_graph
self._process_hook_func()
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/building/imphook.py", line 433, in _process_hook_func
self._hook_module.hook(hook_api)
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/hooks/hook-_tkinter.py", line 245, in hook
hook_api.add_datas(_collect_tcl_tk_files(hook_api))
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/hooks/hook-_tkinter.py", line 208, in _collect_tcl_tk_files
tcl_root, tk_root = _find_tcl_tk(hook_api)
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/hooks/hook-_tkinter.py", line 159, in _find_tcl_tk
bins = selectImports(hook_api.__file__)
File "/home/akaroui/PyInstaller-3.3.1/PyInstaller/depend/bindepend.py", line 493, in selectImports
xtrapath = [os.path.dirname(pth)]
File "/usr/local/python/3.6.1/lib/python3.6/posixpath.py", line 154, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Does anyone have an idea how can I fix this problem ?
Here are more information :
Using Linux - Python3.6
the Scripts where I get the problem do open files and modify their content, and also run some pdflatex-scripts. They are as I mentioned working fine when I run them with Python, the only problem is building the .exe from them.

Too Many Open Files Parallel Python Subprocess error

Questions with similar issue:
Parallel Python - too many files and Python too many open files (subprocesses)
I am using Parallel Python [V1.6.2] to run tasks. The task processes an input file and outputs a log/report. Say, there are 10 folders each with 5000 ~ 20000 files which are read in parallel, processed and logs written out. Each file is approx 50KB ~ 250KB
After ~6 Hours of running, Parallel Python fails with the following error.
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 342, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 506, in set_ncpus
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 140, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 146, in start
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
File "/usr/lib/python2.7/subprocess.py", line 1135, in _execute_child
File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec
OSError: [Errno 24] Too many open files
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
ImportError: No module named fileutils
Original exception was:
Traceback (most recent call last):
File "PARALLEL_TEST.py", line 746, in <module>
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 342, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 506, in set_ncpus
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 140, in __init__
File "/usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py", line 146, in start
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
File "/usr/lib/python2.7/subprocess.py", line 1135, in _execute_child
File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec
OSError: [Errno 24] Too many open files
While I understand, this could be the issue in subprocess pointed out here http://bugs.python.org/issue2320, but, seems the solution is only part of Py V3.2. I am currently tied to Py V2.7.
I would like to know if the following suggestion helps:
[1]http://www.parallelpython.com/component/option,com_smf/Itemid,1/topic,313.0
*) Adding worker.t.close() in destroy() method of /usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/pp.py
*) Increasing BROADCAST_INTERVAL in /usr/local/lib/python2.7/dist-packages/pp-1.6.2-py2.7.egg/ppauto.py
I would like to know if there is a fix available/Work Around for this issue in Python V2.7.
Thanks in Advance
My team recently stumbled upon a similar issue with the same file handle resource exhaustion issue while running celeryd task queue jobs. I believe the OP has nailed it and it's most likely the messy code in suprocess.py lib in Python 2.7 and Python 3.1.
As suggested in , Python Bug#2320, please pass in close_fds=True everywhere you call subprocess.Popen(). In fact they make that a default in Python 3.2 while also fixing the underlying race condition issue. See more details in that ticket.
I had left at some lines to destroy the job servers. job_server.destroy() fixes the issue.

Categories

Resources