making an executable with pyinstall: trouble with vlc module (linux) - python

I want to make an executable out of a gui youtube audio player I made.
There is a problem with the vlc module. When I just make the executable (on Linux), I can't open the file.
Opening in the terminal gives the following error:
Traceback (most recent call last):
File "ytplayer.py", line 39, in
player = instance.media_player_new()
AttributeError: 'NoneType' object has no attribute 'media_player_new'
[24084] Failed to execute script 'ytplayer' due to unhandled exception!
in my code I have:
from vlc import Instance
and
vlc_instance = Instance()
player = vlc_instance.media_player_new()
I found some information on the net about this problem, but no solution yet. This is one post on the internet:
By specifying a VLC_PLUGIN_PATH environment variable, everything works as expected! It's an exciting workaround:
os.environ["VLC_PLUGIN_PATH"] = "/usr/lib64/vlc/plugins"
Problem is: I dont know where my vlc plugins are... So I cant test this.
Does anybody have ideas either for other ways to get around this problem, or to find the path of my vlc plugings?
FYI: My script works perfectly when I dont put it through PyInstaller.
link to the website with the info:
https://github.com/pyinstaller/pyinstaller/issues/4506

Related

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.

I recently uninstalled and reinstalled python and I set it up but there is one problem

I set my python files to open via (python.exe) but they open a close really quick, I managed to record my screen and slow it down and caught this error:
Traceback (most recent call last):
With no error popping up, I spoke to friends about it and could not come to a conclusion, and my files have 0 error and work fine in terminal and vs code but when I double click it it doesn't seem to work. Adding time.sleep() to the code doesn't seem to help either.

Why am I unable to load an image using pygame module?

Following an online game building tutorial on Youtube, I am trying to build a game but whenever i enter this code it always comes out with this syntax error:
line 11, in <module>
icon = pygame.image.load('burger.png')
pygame.error: Couldn't open burger.png
what should I do?
Probably nothing to do with Pygame itself. But your file location. Do you have it in the same folder as your .py script (aka your root folder)? If yes, check this thread out: Opening images with Python

'NameError: name 'fcntl' is not defined' when using urwid on windows

So I just installed Urwid and as a test tried running the Urwid equivalent of a basic print command, as given as an example on the Urwid website tutorial. I received an error message.
I tried running a different one of the examples and received a similar error message. The code looks like this:
import urwid
txt = urwid.Text(u"Hello World")
fill = urwid.Filler(txt, 'top')
loop = urwid.MainLoop(fill)
loop.run()
It should print 'Hello World' in the top left corner of the screen and then run until instructed to quit. Instead I get this error message:
Traceback (most recent call last):
File "C:\Users\Rory Kranz\AppData\Local\atom\app-1.34.0\testingg", line 5, in <module>
loop = urwid.MainLoop(fill)
File "C:\Users\Rory Kranz\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urwid\main_loop.py", line 114, in __init__
screen = raw_display.Screen()
File "C:\Users\Rory Kranz\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urwid\raw_display.py", line 92, in __init__
fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
NameError: name 'fcntl' is not defined
Did something go wrong with the installation, or is there something else I need to install in order to get Urwid to work?
If you want to use urwid, you will need to use it with cygwin (not sure of mingw supports it but it might be worth a try if that's your preference).
Windows does not natively support the fcntl interface and apparently it is not trivial to simulate it using win32 functions.
If you want to remain on windows without a unix emulation environment, you might try curses or python prompt toolkit. I can't be sure these are the best choices as I'm not clear on what exactly you are trying to do.
Some relevant links
Problem over windows platform
NameError: name 'fcntl' is not defined
The previous answer is outdated. Windows does not support the interface however installing the new Linux bash console will suffice.

Python Windows Service - Current Path, Custom Modules, and wrong resolutions

I have a working windows service which is referencing a custom schema created in SQLAlchemy. Before moving everything into a seperate module, everything was working just fine in python form, exe form, and msi form.
I have never imported custom modules before. Right now, I am staticly loading the path of the module into the application. And it seems to work just fine.
Now I moved the code out, set up an import did some work, and my config file is failing to load! I can't figure it out!
The static load --
`sys.path.insert(0,r"c:\dev\nbc_dps_tools\dashboardtotal\schema")
from NydpsSchema import Computer, Drive, Workgroup
`
Seems to get me all the objects I need. Figuring out how to dynamically load the path will be done after I figure out the following pathing problem.
service_dir = os.path.dirname(os.path.realpath("__file__"))
yaml_file = os.path.join(service_dir, 'configs.yaml')
Printing the yaml_file path from above gives me the following path in console, when starting the service
However, after the service starts (successfully) it quickly dies out. Providing the following error in event viewer.
Python could not import the service's module
Traceback (most recent call last):
File "c:\dev\nbc_dps_tools\dashboardtotal\Logon_Service_Live\Logon_Service.py", line 82, in <module>
stream = open(yaml_file, 'r')
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Python34\\lib\\site-packages\\win32\\configs.yaml'
%2: %3
As we see, while installing/starting the service, it resolves properly, gets the config file, and starts. However, once it starts, it appears as if the yaml_file path is resolving to win32 site-package. I tried lots of different pathing styles, nothing seems to work.
The idea is that the path should resolve properly whether run from .py, .exe (or msi)
Thanks for reading, if any additional information is required to help, I can always add more.
EDIT : It appears it is resolving to pythonservice.exe, and not to the script

Categories

Resources