【问题标题】:python word2vec not installingpython word2vec没有安装
【发布时间】:2014-10-27 21:02:08
【问题描述】:

我一直在尝试使用我的 Python2.7 解释器在我的 Windows 7 机器上安装 word2vec:https://github.com/danielfrg/word2vec

我已尝试从解压缩的目录下载 zip 并运行 python setup.py install 并运行 pip install。但是在这两种情况下,它都会返回以下错误:

Downloading/unpacking word2vec
  Downloading word2vec-0.5.1.tar.gz
  Running setup.py egg_info for package word2vec
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "c:\users\georgioa\appdata\local\temp\pip_build_georgioa\word2vec\setup.py", line 17, in <module>
        subprocess.call(['make', '-C', 'word2vec-c'])
      File "C:\Python27\lib\subprocess.py", line 524, in call
        return Popen(*popenargs, **kwargs).wait()
      File "C:\Python27\lib\subprocess.py", line 711, in __init__
        errread, errwrite)
      File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
        startupinfo)
    WindowsError: [Error 2] The system cannot find the file specified
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>
  File "c:\users\georgioa\appdata\local\temp\pip_build_georgioa\word2vec\setup.py", line 17, in <module>
    subprocess.call(['make', '-C', 'word2vec-c'])
  File "C:\Python27\lib\subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\lib\subprocess.py", line 711, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

访问subprocess.call() 似乎有问题,所以经过一番谷歌搜索后,我设法将shell=True 添加到word2vec setup.py 的行中,然后抛出此错误:

'make' is not recognized as an internal or external command,
operable program or batch file.
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running install
running build
running build_py
running install_lib
running install_data
error: can't copy 'bin\word2vec': doesn't exist or not a regular file 

说实话,我什至不确定我应该从这里去哪里。我还尝试安装 make 并将路径变量设置为安装中的 .exe 文件,任何建议将不胜感激,谢谢。

更新:

虽然 word2vec 模块无法运行名为 genism 的包似乎运行良好,但它也有一些很棒的其他 NLP 功能 http://radimrehurek.com/gensim/

【问题讨论】:

    标签: python pip gnuwin32 word2vec


    【解决方案1】:

    word2vec 适用于 Linux。见:https://github.com/danielfrg/word2vec

    在底部它说有一个非常实验性的 Windows 版本:support:https://github.com/zhangyafeikimi/word2vec-win32

    编辑:

    看来你也可以安装gensim:https://pypi.python.org/pypi/gensim

    然后做:

    from gensim.models import word2vec
    

    【讨论】:

      【解决方案2】:

      对我来说,这种方法适用于 Win 7 和 Win 8。

      1. 安装 Anaconda 64 位(Python 2.7 版)
      2. 安装 MinGW Basic 编译器(确保在安装列表中选择 C ​​和 C++ 编译器)
      3. 使用命令“conda install gensim”在 Anaconda 上重新安装 gensim 然后你可以打开 ipython-notebook 并尝试使用 word2vec 运行 python 代码,它应该可以工作。

      【讨论】:

      • 如@WilliamRoss 的回答中所述,要从gensim 运行word2vec,您需要from gensim.models import word2vec
      【解决方案3】:

      使用pip安装Python库是一种很好的方法。

      1.安装pip

      a)作为管理员的命令提示符启动

      1. 单击开始,单击所有程序,然后单击“附件”。

      2. 右键单击命令提示符,然后单击以管理员身份运行。

      3. 如果出现了用户帐户控制对话框,请确认它显示的操作是您想要的,然后单击“继续”。

      b)下载get-pip.py,小心保存为.py文件而不是.txt。然后,从命令提示符运行它。

      python get-pip.py

      下载get-pip.py,将其另存为get-pip.py(不是get-pip.txt)。

      从命令提示符运行它。

      python get-pip.py
      

      2。安装Word2vec

      现在您可以使用

      安装它
      pip install word2vec
      

      【讨论】:

      • 谢谢Anand,我认为我在上面提到我尝试过运行setup.py和使用pip安装:) span>
      • @ pygeorgiou安装anaconda然后安装word2vec。 span>
      • 试图通过Conda Install和Conda PyBuild运行它,它仍然无法正常工作。你认为它是与我的硬件有关吗? span>
      • 我不认为硬件是一个问题! span>
      【解决方案4】:

      看起来这个包包含 C 代码并调用 UN*X 生成文件,所以它不是为 Windows 编写的。您可以尝试查找预编译的 Windows 二进制文件。

      【讨论】:

      • 谢谢,我没想到。我以前用过这个网站。但看起来他们没有lfd.uci.edu/~gohlke/pythonlibs你知道其他地方吗?
      • 按原样标记为正确答案,但不幸的是 word2vec 模块没有预编译的二进制文件。我找到了一个解决方案,我将在问题中作为更新发布
      【解决方案5】:

      我能够使用 Cygwin 在 Windows 上成功编译和运行原始 word2vec 代码 (https://github.com/dav/word2vec)。也就是说,无论如何我更喜欢 gensim 包——它对 UTF-8 没有问题,而原始代码在非 ASCII 字符上会阻塞。

      【讨论】:

        【解决方案6】:

        word2vec 进来 scipy version 1.2.0 并且大多数安装的 scipy 版本是 1.1

        对于 anaconda,您需要使用此通用 conda install -c anaconda scipy 下载 Scipy

        这将安装您当前的 scipy 版本...

        然后你需要安装gensim 使用这个command conda install -c conda-forge gensim

        我希望这会对你有所帮助...

        【讨论】:

          猜你喜欢
          • 2014-10-03
          • 1970-01-01
          • 2022-10-06
          • 2012-05-06
          • 2023-03-31
          • 2017-09-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多