Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script with python-vlc module failed after bundled by pyinstaller #3448

Closed
Tracked by #356
safecorner opened this issue Apr 8, 2018 · 6 comments
Closed
Tracked by #356
Labels
solution:not enough info Not enough info has been provided to solve or help. Fill out the issue template

Comments

@safecorner
Copy link

safecorner commented Apr 8, 2018

ENV:
windows 10 simple Chinese version
python 3.6.5
pip 9.0.3
pyinstaller 3.4.dev0+f482da7bc
python_vlc-1.1.2-py3.6.egg
vlc media player 3.0.0 Vetinari

PACKING COMMAND:
pyinstaller sample.py --onedir --debug --noupx --workpath=d:\windows\ktvbuild --distpath=.

TEST SCRIPT:
test script sample.py :

import vlc

class VLC:
	def __init__(self):
		self.instance = vlc.Instance()
		if self.instance is None:      # atfer bundled self.instance is None
			raise Exception('VLC can not create a Instance')
		self.player = self.instance.media_player_new()


if __name__ == '__main__':
	import sys
	vlci = VLC()
	sys.exit(0)

RUN WITH PYTHON
python sample.py
run sample.py with python, it done correct,

RUN smple.exe
go

Traceback (most recent call last):
  File "sample.py", line 17, in <module>
  File "sample.py", line 7, in __init__
Exception: VLC can not create a Instance
@htgoebel
Copy link
Member

htgoebel commented Apr 8, 2018

Well, this gives no explanation why it fails, thus you need to debug this yourself. Most propably not all required files are packages. Please have a look at Make sure everything is packaged correctly for tips to find out what is missing.

@safecorner
Copy link
Author

Thanks, The VLC contains a plugin folder, I just copy the plugins folder from VLC installation folder to the bundled folder, and then it work correctly.

@htgoebel htgoebel added the solution:not enough info Not enough info has been provided to solve or help. Fill out the issue template label Sep 1, 2018
@jspking
Copy link

jspking commented Jan 30, 2019

Here is the same issue but on linux.

I placed plugins directory in "dist/[my application name]" with symbolic link. However I encounter
"main libvlc error: No plugins found! Check your VLC installation." error.

Could you explain this with more detail?

@jspking
Copy link

jspking commented Jan 30, 2019

Hurray, I figured it out.

Let's say your application name is vlc-example. Your working directory looks like below

vlc-example/
└── examples_tkvlc.py

You would run pyinstaller in vlc-example.
crong@crong-H270-HD3:~/work/personal/jspkingproject/python/vlc-example$ pyinstaller examples_tkvlc.py
And when you run the packaged application 'examples_tkvlc' in dist/examples_tkvlc, you will get error like main libvlc error: No plugins found! Check your VLC installation.

To fix this error,
Just copy the whole vlc plugins directory making vlc directory in dist/examples_tkvlc. This is somewhat confusing... My English sucks. Just see below directory structure.

dist
└── examples_tkvlc
├── tcl
│   ├── encoding
│   ├── http1.0
│   ├── msgs
│   ├── opt0.4
│   └── tcl8
│   └── platform
├── tk
│   ├── images
│   ├── msgs
│   └── ttk
└── vlc
└── plugins (<--- under vlc directory)
├── access (<--- under plugins directory for all of the directories below this line)
├── access_output
├── audio_filter
├── audio_mixer
├── audio_output
├── codec
├── control
├── demux
├── gui
├── lua
├── meta_engine
├── misc
├── mmx
├── mux
├── notify
├── packetizer
├── services_discovery
├── sse2
├── stream_filter
├── stream_out
├── text_renderer
├── video_chroma
├── video_filter
├── video_output
└── visualization

And one more tip. If you want to make one-file bundled application, you should let pyinstaller know all the libraries in plugins directories with their directory hierarchy in spec file. Please find attached spec file.

I hope this helps.

sv_ui_main.spec.txt

@safecorner
Copy link
Author

safecorner commented Jan 31, 2019 via email

@MateKristof
Copy link

MateKristof commented Apr 2, 2020

I have a three +1 step solution for this problem:

Working with pyinstaller onefile "exe" like a charm

  1. Copy the "VLC" folder from the C:\Program Files\VideoLAN

  2. Paste only the VLC\plugin folder and the 2 dll files to the project root folder:

    • PycharmProjects\root\VLC\libvlc.dll
    • PycharmProjects\root\VLC\libvlccore.dll
    • PycharmProjects\root\VLC\plugins
  3. Install and use Python 3.8 interpreter and use this code section to import vlc:

try:
    # PyInstaller creates a temp folder and stores path in _MEIPASS
    base_path = sys._MEIPASS
except AttributeError:
    base_path = os.path.abspath(".")

# Python 3.8 things:
with os.add_dll_directory(os.path.join(base_path, "VLC")):
    import vlc

+1. Don't forget to add "VLC" folder to .spec file, like this:

datas=[('C:/Users/******/PycharmProjects/root/VLC', 'VLC/')],

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
solution:not enough info Not enough info has been provided to solve or help. Fill out the issue template
Projects
None yet
Development

No branches or pull requests

4 participants