无法在Python 3中安装hmmlearn

2024-10-06 08:59:42 发布

您现在位置:Python中文网/ 问答频道 /正文

Failed building wheel for hmmlearn Command "C:\Users\Akash\PycharmProjects\hello\venv\Scripts\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Akash\AppData\Local\Temp\pycharm-packaging\hmmlearn\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\Akash\AppData\Local\Temp\pip-record-z6k7p8b8\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Akash\PycharmProjects\hello\venv\include\site\python3.6\hmmlearn" failed with error code 1 in C:\Users\Akash\AppData\Local\Temp\pycharm-packaging\hmmlearn\

这是cmd和pycharm中显示的错误。 我发现微软Visual Studio C++ 14是必需的


Tags: installhellovenvlocalcoderecordusersappdata
3条回答

我有同样的问题,问我微软Visual Studio C++ 14的构建工具,我已经尝试了我在{{CD1>}和^ {CD2>}上看到的每一个可能的解决方案。 唯一对我有效的修复方法是在https://www.lfd.uci.edu/~gohlke/pythonlibs/#hmmlearn中使用.whl文件,更重要的是使用32位版本的whl文件(我刚刚意识到在64位Win10操作系统中使用的是32位Python3.6)

在特定的.venv文件夹中,激活环境并键入:

pip install <yourdir>/hmmlearn‑0.2.1‑cp36‑cp36m‑win32.whl

以管理员身份运行anaconda prompt并尝试以下命令“conda install-c conda forge hmmlearn”,该命令从另一个通道安装包,或从链接尝试任何其他通道: https://anaconda.org/search?q=hmmlearn

有两种方法可以解决需要Microsoft生成工具的包的问题:

1)为Python使用Anaconda包。如果您的Python包是与Anaconda一起提供的,那么您只需要conda install hmmlearn。就我个人而言,所有的包生成错误都是用这个来修复的。

2)如果您独立安装了Python,请按照以下步骤进行修复:

a)对于Python 3.5,3.6:下载并安装Microsoft Visual C++ Build Tools 2017

b)在Visual Studio下载页上,向下滚动并选择“Visual Studio 2017工具”。单击Build Tools for Visual Studio 2017的下载按钮。

c)重新启动计算机并尝试使用pip install hmmlearn安装hmmlearn。

3)在某些情况下,如果包生成错误仍然存在,可以考虑使用wheels生成包。

我希望这能有帮助。

相关问题 更多 >