FileNotFoundError: 找不到模块“libvlc.dll" [英] FileNotFoundError: Could not find module 'libvlc.dll'

查看:256
本文介绍了FileNotFoundError: 找不到模块“libvlc.dll"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Python 3.8.0,64 位

Using Python 3.8.0, 64 bit

操作系统:Windows 10 Pro,版本 10.0.15063 Build 15063,64 位

OS: Windows 10 Pro, Version 10.0.15063 Build 15063, 64 bit

VLC,3.0.8 Vetinari,64 位

VLC, 3.0.8 Vetinari, 64 bit

已通过 PIP 安装 Python VLC 绑定

Have installed Python VLC Bindings through PIP

VLC 的路径和 libvlc.dll 的直接路径都在我的PYTHONPATH"和PATH"环境变量中.

The path to VLC and the direct path to libvlc.dll are both in my "PYTHONPATH" and "PATH" environment variables.

我正在通过 Windows 命令提示符运行我的脚本.

I am running my script via the Windows command prompt.

我试图运行的脚本是一行:

The script i'm trying to run is one line:

import vlc

这是命令提示符告诉我的:

Here is what the command prompt is telling me:

Traceback (most recent call last):
  File "001.py", line 1, in <module>
    import vlc
  File "C:\Program Files\Python38\lib\site-packages\vlc.py", line 207, in <module>
    dll, plugin_path  = find_lib()
  File "C:\Program Files\Python38\lib\site-packages\vlc.py", line 163, in find_lib
    dll = ctypes.CDLL(libname)
  File "C:\Program Files\Python38\lib\ctypes\__init__.py", line 369, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libvlc.dll'. Try using the full path with constructor syntax.

我是 Python 新手,任何帮助将不胜感激!

I'm new to Python, any help would be greatly appreciated!

推荐答案

来自 Python 3.8 发行说明:

From the Python 3.8 release notes:

Windows 上使用 ctypes 加载的扩展模块和 DLL 的 DLL 依赖项现在可以更安全地解析.仅搜索系统路径、包含 DLL 或 PYD 文件的目录以及使用 add_dll_directory() 添加的目录以查找加载时依赖项.具体来说,不再使用 PATH 和当前工作目录,对它们的修改将不再对正常的 DLL 解析产生任何影响.如果您的应用程序依赖于这些机制,您应该检查 add_dll_directory() 并且如果它存在,在加载您的库时使用它来添加您的 DLL 目录.请注意,Windows 7 用户需要确保已安装 Windows Update KB2533623(这也由安装程序验证).

DLL dependencies for extension modules and DLLs loaded with ctypes on Windows are now resolved more securely. Only the system paths, the directory containing the DLL or PYD file, and directories added with add_dll_directory() are searched for load-time dependencies. Specifically, PATH and the current working directory are no longer used, and modifications to these will no longer have any effect on normal DLL resolution. If your application relies on these mechanisms, you should check for add_dll_directory() and if it exists, use it to add your DLLs directory while loading your library. Note that Windows 7 users will need to ensure that Windows Update KB2533623 has been installed (this is also verified by the installer).

PATH 或 cwd 不能再使用了,除非您专门将这些目录添加到 dll 搜索路径中.

PATH or cwd cannot be used any more unless you specifically add these directories to the dll search path.

将 cwd 添加到搜索路径:

To add cwd to search path:

import os
os.add_dll_directory(os.getcwd())

大多数库都提供了一个环境变量来指定 dll 位置.这将使用路径加载 dll,这是可行的.

Most libraries offer an environment variable to specify the dll location. That would load the dll with with the path, something that work.

许多包将不得不为 py38 清理它们的库加载并决定如何处理这个问题.它目前是很多混乱的来源.

A lot of packages will have to clean up their library loading for py38 and decide how to handle this. It's currently a source for a lot of confusion.

这篇关于FileNotFoundError: 找不到模块“libvlc.dll"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆