简体   繁体   English

TypeError:LoadLibrary() 参数 1 必须是 str,而不是 None

[英]TypeError:LoadLibrary() argument 1 must be str, not None

I have been trying to learn SpeechRecognition in python, so I decided working with code provided by Picovoice Github, When I tried running the script in Colab it works fine.我一直在尝试在 python 中学习 SpeechRecognition,所以我决定使用 Picovoice Github 提供的代码,当我尝试在 Colab 中运行脚本时它工作正常。 But it fails to do so when I run in my desktop.但是当我在我的桌面上运行时它没有这样做。

C:\Users\ELCOT\Downloads\cheetah-master\cheetah-master>python demo/python/cheetah_demo.py --audio_paths resources/audio_samples/test.wav --license_path license_cta_v1.2.0_linux_expires_2020-08-27.lic
Traceback (most recent call last):
  File "demo/python/cheetah_demo.py", line 61, in <module>
    license_path=args.license_path)
  File "demo/python\../../binding/python\cheetah.py", line 63, in __init__
    self._libc = CDLL(find_library('c'))
  File "C:\Python 36\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None

I tried with Anaconda too, it shows me the same error.我也试过 Anaconda,它显示了同样的错误。 I am stuck in this for couple of week, please help.我被困在这几个星期了,请帮忙。 (I am using python 3.6.8 X64 in win 10) Will completely reinstalling anaconda do the work? (我在 win 10 中使用 python 3.6.8 X64) 完全重新安装 anaconda 会起作用吗?

The error you experience comes from poor code you got from GitHub that does no error checking.您遇到的错误来自您从没有错误检查的 GitHub 获得的糟糕代码。

The relevant trace is:相关的跟踪是:

self._libc = CDLL(find_library('c'))
self._handle = _dlopen(self._name, mode)
LoadLibrary()

It appears the find_library call could not locate the C library and so returned the value None .看来find_library调用无法找到 C 库,因此返回值None

That value is then used in the dlopen call which underneath uses the LoadLibrary function of the Windows API.然后在dlopen调用中使用该值,该调用在下面使用 Windows API 的LoadLibrary function。 However, this now uses an unknown name or empty parameter None and consequently fails.但是,这现在使用未知名称或空参数None并因此失败。

On https://docs.python.org/2.5/lib/ctypes-finding-shared-libraries.html :https://docs.python.org/2.5/lib/ctypes-finding-shared-libraries.html 上

find_library(name) : Try to find a library and return a pathname. find_library(name) :尝试查找库并返回路径名。

On Windows, find_library searches along the system search path, and returns the full pathname, but since there is no predefined naming scheme a call like find_library("c") will fail and return None.在 Windows 上,find_library 沿着系统搜索路径搜索,并返回完整的路径名,但由于没有预定义的命名方案,像 find_library("c") 这样的调用将失败并返回 None。

So a solution could be to add the location of the library (probably libc.lib ) to the PATH environment variable.因此,一种解决方案可能是将库的位置(可能是libc.lib )添加到PATH环境变量中。

You can't run the free version of Cheetah on Windows, it simply isn't supported.您无法在 Windows 上运行 Cheetah 的免费版本,它根本不受支持。 The code in the GitHub repository only supports Linux. GitHub 存储库中的代码仅支持 Linux。

The fourth bullet point in the README is as follows (emphasis mine):自述文件中的第四个要点如下(强调我的):

  • cross-platform.跨平台。 Linux (x86_64), Mac (x86_64), Windows (x86_64), web browsers, Android, iOS, Raspberry Pi, and BeagleBone are supported. Linux (x86_64), Mac (x86_64), Windows (x86_64), web browsers, Android, iOS, Raspberry Pi, and BeagleBone are supported. Linux (x86_64) is available for personal and non-commercial use free of charge. Linux (x86_64) 可免费用于个人和非商业用途。 Other platforms are only available under the commercial license.其他平台仅在商业许可下可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM