Trouble including PyOpenAL and PyOgg using PyInstaller - python

I'm using pyinstaller to try and turn a pygame program into an EXE file, and the pygame library runs fine but PyOpenAl (an external sound library I'm using) just won't import correctly. Every time I run the EXE I get this error:
File "snd_music_player.py", line 5, in __init__
self.music = oalOpen("music/title.ogg")
File "openal\__init__.py", line 836, in oalOpen
File "openal\__init__.py", line 113, in _no_pyogg_error
File "openal\__init__.py", line 58, in _err
openal.OalError: You have to set up pyogg in order to use this function. Go to https://github.com/Zuzu-Typ/PyOgg to get it
Even though PyOgg is very much installed. I tried running the program on another computer, and a new error popped up that apparently PyOpenAL wasn't included either. I've tried using --hidden-import but it doesn't seem to work. Is there any other way to properly force PyOpenAL and PyOgg to be packaged?

Related

Faulty Python script after using SFTP

I have a running python program I wrote in thonny.
Everything worked perfectly fine, when I ran it from the IDE and the terminal.
I run SSH on the Raspberry Pi I'm using for this application to start my program. Then I tried using SFTP to download the files the program puts out.
This worked too, but when I tried to start the program again, it suddenly errored out at (4th line, rest for context):
#PYGAME SETUP FOR SOUNDS
pygame.init()
pygame.mixer.init()
shuttersound = pygame.mixer.Sound('Shutter.wav')
savesound = pygame.mixer.Sound('Save.wav')
with:
Traceback (most recent call last):
File "/home/pi/Desktop/PictographBox/PictographBox_v1.1.py", line 19, in <module>
shuttersound = pygame.mixer.Sound('Shutter.wav')
pygame.error: Unable to open file 'Shutter.wav'
although the sound file remained unchanged.
I could still run the program perfectly fine from thonny.
I ran "dos2unix" on my script and it worked as expected again.
So I tried to use SFTP again and that produced the exact same problem on the same line (again fixed by "dos2unix").
I need to prevent this from happening, as downloading the files is crucial.
I first thought it was my FTP client, but I tried three different clients which produced the exact same result.
I didn't even open or otherwise touch the script with SFTP, just went into the folder.
Do I have a problem in my script?
All line breaks look fine.
No other files have problems, only my script and only after opening it's folder via SFTP.

Setup file cannot be installed on other computers

I created an installer file using nsis. After running the programme on my system, it worked flawlessly but when installed on third party system, it complained on launching the app.
Traceback (most recent call last):
File "Classify.py", line 20, in <module>
File "tkinter\_init_.py", line 2109, in wm_iconbitmap
_tkinter.TclError: bitmap "D:\Users\Engr M2J\Documents\GitHub\HAM1000-Image-Classifier\logo.ico" not defined
I know this is where the error is coming from;
root.title("HAM10000 Image Classifier by Engr. Sule Muhammed Abba- BookNowNow Code version 1.1.0")
root.iconbitmap(r'D:\Users\Engr M2J\Documents\GitHub\HAM1000-Image-Classifier\logo.ico')
it is actually referencing my computer path instead of it to be relative. This is the only way I could get the icon to load by using it direct path. whenever I use the below code, I get the error that follows;
root.iconbitmap('logo.ico')
I get this error
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "logo.ico" not defined
Please assist
Here are the steps taken to solve the problem.
I printed the working directory.
print(getcwd())
I then copied all code files to this directory
By doing this, I was able to load the icon using
root.iconbitmap(r'logo.ico')
My new software now runs seamlessly on different systems without any complain.
Any better solution is welcome but this will work perfectly.

How to run a Python file from a Batch File with Anaconda prompt on Windows 10?

I created a script in python and I need it to run in way that the python code is not visible. I tried different methods like implementing nodeJS and PHP, but to no avail. So, I thought of using a .bat file to run the python file. I created a bat file for the python script, but on clicking the batch file all I got was an error saying that a module was missing in the code. The code works perfectly when I run it in Spyder and on the Anaconda Prompt. So, I thought of running the file from a batch file via the Anaconda Prompt. The code in the batch file is below:
%windir%\System32\cmd.exe /K ""C:\Program Files\Anaconda3\Scripts\activate.bat" "C:\Program Files\Anaconda3""
python myscript.py
pause
The .bat file now opens a command prompt in the python environment, but does not run the python file. I tried altering the code, but it was always the same result. If I type:
python myscript.py
into the next line in the command prompt, the python file gets executed. I need to find a way for the file to be executed without typing anything in the prompt. The python file contains GUI from tkinter and the shebang line has the python version (3.7.4). I work with Windows 10.
I tried this code in the batch file as well,
"C:\Program Files\Anaconda3\python.exe" "C:\Users\Sathya\Desktop\myscript.py"
pause
All this did was open and close the command prompt in the blink of an eye. I tried to run the bat file a few more times, but got the same result. But, this code worked on a different file (also with tkinter GUI) myscript_test.py and this one gave the GUI window correctly. I don't have a clue as to why it worked on the second one and not the first one.

Runnable exe error after using pyinstaller to convert from python

I tried to convert a python file to an exe file to run in another computer which not install python and library. I used pyinstaller and its success to make an exe file. But, when I run it(.exe) an error appears:
In my function, the error in this line:
pyautogui.click()
The function mouse movement pyautogui.moveTo(536, 49, 2, pyautogui.easeInOutQuad)work ok but stuck and waring error at pyautogui.click().
So, is the reason for the error caused by pyautogui lib? And have any idea to fix it? I using python 3.5 and as I know have only pyinstaller work with.

Opening PyGTK Python Module Error in py2exe

I have a project written in Python 2.7 and PyGTK, with py2exe for compiling. I have two modules, "Launchpad.py" and "RegistrationScreen.py". I need to open RegistrationScreen.py from Launchpad.py.
I am using the following code currently:
def open_registration(event, data=None):
subprocess.Popen(["python", "RegistrationScreen.py"])
This works fine when I test - the window is opened without the shell window opening.
However, when I compile using py2exe, I get the following log error on executing the created application.
Traceback (most recent call last): File "Launchpad.py", line 26, in
open_registration File "subprocess.pyc", line 672, in init
File "subprocess.pyc", line 882, in _execute_child WindowsError:
[Error 2] The system cannot find the file specified
How do I fix my code so py2exe will compile it correctly? Is there another way I can open the RegistrationScreen.py module's window from Launchpad.py, that won't throw errors in the final .exe file?
The problem is the path. RegistrationScreen.py is (probably) compressed inside dist/library.zip, but your code that calls it is looking for it in dist/RegestrationScreen.py.
I don't know what the best solution to this is... py2exe is kind of a pain for accessing files.
Also, you probably don't want to be doing subprocess.Popen(["python", "RegistrationScreen.py"]) because you can't guarantee your users will have python installed and accessible systemwide. If you really need a separate process, then maybe you should run py2exe on RegistrationScreen.py individually to create a separate .exe, and then include that in the dist folder of your main .exe?
I know that's somewhat convoluted, but it would probably work. And as I said, there might be a better way.

Categories

Resources