10

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

我尝试setup.py从解压缩的目录下载 zip & running python 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=Trueword2vec 添加到该行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/

4

6 回答 6

16

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

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

编辑:

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

然后做:

from gensim.models import word2vec
于 2016-03-09T19:25:17.963 回答
3

对我来说,这种方法适用于 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 代码,它应该可以工作。
于 2015-12-17T01:11:37.733 回答
1

使用pip安装 python 库是一个很好的方法。

1.安装点子

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
于 2014-09-03T12:22:48.873 回答
0

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

于 2014-09-03T12:38:32.717 回答
0

word2vec进来,scipy version 1.2.0安装的大多是 scipy verion1.1

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

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

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

我希望这会帮助你...

于 2019-04-16T06:06:42.923 回答
0

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

于 2018-02-08T14:43:17.817 回答