• 安装gensim


    安装了一天的gensim,其中因为版本不一致等等各种问题纠结了好久,现记录如下:

    正确安装方式:

    1. 安装python2.7

    2. 下载Python Extension Packages对应版本的numpy、scipy、gensim

    3. 进入python安装目录下的Scripts目录

        执行: pip install numpy***.whl

                   pip install scipy***.whl

                   pip install gensim.whl

       测试:输入python命令进入python命令行,分别输入 import numpy; import scipy; import gensim;没有报错,即安装成功!

    很简单啊~可是我就是倒腾了一天,原因大体归结为 版本不一致。

    1. 原本机子上是有numpy和scipy的,但是以前貌似安装的win32版本的扩展包,存在冲突,所以gensim安装不了。

    2. 卸载了原先装的numpy和scipy,参照 官网Gensim Installation,使用pip或者easy_install安装numpyscipy,numpy成功,scipy报错“LAPACK and BLAS libraries not found”,

    解释1解释2解释3等等都提到说需要Microsoft Visual C++ Compiler for Python 2.7,可是还是报这个错。

    3. 安装时还遇到问题 —安装第三方库出现 Python version 2.7 required, which was not found in the registry

       运行脚本

    import sys
      
    from _winreg import *
      
    # tweak as necessary
    version = sys.version[:3]
    installpath = sys.prefix
      
    regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)
    installkey = "InstallPath"
    pythonkey = "PythonPath"
    pythonpath = "%s;%s\Lib\;%s\DLLs\" % (
        installpath, installpath, installpath
    )
      
    def RegisterPy():
        try:
            reg = OpenKey(HKEY_CURRENT_USER, regpath)
        except EnvironmentError as e:
            try:
                reg = CreateKey(HKEY_CURRENT_USER, regpath)
                SetValue(reg, installkey, REG_SZ, installpath)
                SetValue(reg, pythonkey, REG_SZ, pythonpath)
                CloseKey(reg)
            except:
                print "*** Unable to register!"
                return
            print "--- Python", version, "is now registered!"
            return
        if (QueryValue(reg, installkey) == installpath and
            QueryValue(reg, pythonkey) == pythonpath):
            CloseKey(reg)
            print "=== Python", version, "is already registered!"
            return
        CloseKey(reg)
        print "*** Unable to register!"
        print "*** You probably have another Python installation!"
        
    if __name__ == "__main__":
        RegisterPy()

    3. 后来我试了pip install scipy**.whl 方法,安装scipy成功但是gensim不行,Github 解压,使用命令:python setup.py install ,安装有错。

    4. 使用pip装whl文件,导入测试时有错误。

    显示scipy包有问题。

    5. 卸载了numpy、scipy,使用前面说的方法重新来过,就可以了。。

    这个故事告诉我们,凡事都要从一而终,都是用pip install ***.whl才行。

  • 相关阅读:
    MSSQL·FOR XML PATH语法转义尖括号解决方案
    代码上传Github后乱码解决方案
    MSSQL·CONCAT函数的基础使用
    使用URL快捷方式提高效率
    数组逆序
    C++默认拷贝构造
    HO引擎近况20220512
    老猿谈谈对Tensorflow的理解
    学习笔记——Python中的IO问题理解
    PHP接口报错:Unable to init from given binary data
  • 原文地址:https://www.cnblogs.com/yiruparadise/p/5645238.html
Copyright © 2020-2023  润新知