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

Error When Importing VLC #140

Closed
kethan1 opened this issue Jun 16, 2020 · 20 comments · May be fixed by #144
Closed

Error When Importing VLC #140

kethan1 opened this issue Jun 16, 2020 · 20 comments · May be fixed by #144

Comments

@kethan1
Copy link

kethan1 commented Jun 16, 2020

I am using 64-bit python 3.8.3. I have install vlc using pip install python-vlc. I am getting the following error:

Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import vlc File "C:\Users\--\AppData\Local\Programs\Python\Python38\lib\site-packages\vlc.py", line 210, in <module> dll, plugin_path = find_lib() File "C:\Users\--\AppData\Local\Programs\Python\Python38\lib\site-packages\vlc.py", line 170, in find_lib dll = ctypes.CDLL('.\\' + libname) File "C:\Users\--\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__ self._handle = _dlopen(self._name, mode) FileNotFoundError: Could not find module 'C:\Users\--\AppData\Local\Programs\Python\Python38\libvlc.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Edit: I am using Windows, and I have installed VLC before installing the python module.

@oaubert
Copy link
Owner

oaubert commented Jun 16, 2020

@pjeanjean do you have an idea? Since this occurs on windows (that I do not use) and seems to be impacted by your patch.

@pjeanjean
Copy link
Contributor

From the message, I am guessing that VLC is not installed on the computer (or at least that the install path was not found from the registry), and python-vlc resorted to try and get the dll from the working directory.
Now, for some reason, the working directory as seen by the Python Interpreter is C:\Users\--\AppData\Local\Programs\Python\Python38\, and I'm honestly not sure why, might be my bad because of a missing chdir but I do remember testing this and concluding that was not necessary.

I would like to look a bit more into it, but I don't have my Windows computer with me at the moment.

In the meantime:

I have install vlc using pip install python-vlc

Please note that this command will not install VLC, but only this Python library, and you need to install VLC independently.

@kethan1
Copy link
Author

kethan1 commented Jun 16, 2020

Yes, I have installed vlc separately before I installed the vlc python module. I am running windows 10.

@kethan1 kethan1 closed this as completed Jun 16, 2020
@kethan1 kethan1 reopened this Jun 16, 2020
@kethan1
Copy link
Author

kethan1 commented Jun 16, 2020

Sorry, accidently closed issue.

@pjeanjean
Copy link
Contributor

Can you check your registry?
The library is supposed to get the registry key HKEY_LOCAL_MACHINE/Software/VideoLAN/VLC/InstallDir and use it to find libvlc.dll.
If this fails, it should look directly for "Program Files/VideoLan/VLC/libvlc.dll".

In your case, the registry key is not found, and the direct lookup also fails (where is VLC installed, and can you see the dll in the directory?)

@kethan1
Copy link
Author

kethan1 commented Jun 16, 2020

Hi, for me, it is located in "C:\Program Files (x86)\VideoLAN\VLC\libvlc.dll".
BTW, in HKEY_LOCAL_MACHINE/Software, VideoLAN does not exist.

@pjeanjean
Copy link
Contributor

pjeanjean commented Jun 18, 2020

Well, as a temporary workaround you could put the dll inside C:\Users\--\AppData\Local\Programs\Python\Python38 if you want to use the library anyway.

Last question (for now): did you install VLC through the official installer, or did you use some kind of package manager (Microsoft Store, choco, ...)?

I will try to reproduce this issue when I have access to my Windows computer.

(I guess that adding Program Files (x86) as a default location would make sense and fix the issue, but I at least want to check how to do it properly)

@kethan1
Copy link
Author

kethan1 commented Jun 18, 2020

I have used the official installer. It is not urgent, so I will wait for a bug fix.

@kethan1 kethan1 closed this as completed Jun 18, 2020
@kethan1
Copy link
Author

kethan1 commented Jul 22, 2020

Any update on this? The error still happens. Do I need to upgrade python to Python 3.8.5 instead of Python 3.8.3.?

@kethan1 kethan1 reopened this Jul 22, 2020
@pjeanjean
Copy link
Contributor

Sorry, I forgot all bout this but I'll make a PR this evening to fix it.
Updating your Python version shouldn't change anything, we just need to add Program Files (x86) to the list of directories where VLC might be installed.

@kethan1
Copy link
Author

kethan1 commented Jul 22, 2020

Oh, okay, thank you so much.

@pjeanjean
Copy link
Contributor

Just to be sure, could you try with this commit?
pjeanjean@bf63e87

@kethan1
Copy link
Author

kethan1 commented Jul 22, 2020

I tried doing python setup.py install and I got this:

C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
  warnings.warn(
C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\site-packages\setuptools\dist.py:472: UserWarning: The version specified ('%s"') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
  warnings.warn(
running install
running bdist_egg
running egg_info
creating python_vlc_generator.egg-info
writing python_vlc_generator.egg-info\PKG-INFO
writing dependency_links to python_vlc_generator.egg-info\dependency_links.txt
writing top-level names to python_vlc_generator.egg-info\top_level.txt
writing manifest file 'python_vlc_generator.egg-info\SOURCES.txt'
error: package directory 'generator/generate' does not exist

@pjeanjean
Copy link
Contributor

Close, run setup.py from generated/3.0 ;)

@kethan1
Copy link
Author

kethan1 commented Jul 22, 2020

The first time I import it, I get this error:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import vlc
  File "C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\site-packages\python_vlc-3.0.11114-py3.8.egg\vlc.py", line 223, in <module>
    dll, plugin_path  = find_lib()
  File "C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\site-packages\python_vlc-3.0.11114-py3.8.egg\vlc.py", line 172, in find_lib
    dll = ctypes.CDLL('.\\' + libname)
  File "C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

The second time I import it, it gives me this error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import vlc
  File "C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\site-packages\python_vlc-3.0.11114-py3.8.egg\vlc.py", line 223, in <module>
    dll, plugin_path  = find_lib()
  File "C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\site-packages\python_vlc-3.0.11114-py3.8.egg\vlc.py", line 186, in find_lib
    dll = ctypes.CDLL(p)
  File "C:\Users\ketha\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libvlc.dll' (or one of its dependencies). Try using the full path with constructor syntax.

BTW: it says it's installed in c:\users\ketha\appdata\local\programs\python\python38\lib\site-packages\python_vlc-3.0.11114-py3.8.egg

@pjeanjean
Copy link
Contributor

Weird, this time it actually found the dll but couldn't load it.
Are you using a 32bit version of Python by any chance?

@kethan1
Copy link
Author

kethan1 commented Jul 22, 2020

No, I am using python 64bit.

I downloaded the 64bit version from python.org, and it is located in python38 not python38-32

@pjeanjean
Copy link
Contributor

Oh, so maybe the issue is that your version of vlc is 32bits while your Python is 64 (which would also explain why it is installed in Program Files (x86))

@pjeanjean
Copy link
Contributor

Well, mine is:

libvlc.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows

And the website has both options for download

@kethan1
Copy link
Author

kethan1 commented Jul 22, 2020

Okay, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants