10

I've been trying to install word2vec on my Windows 7 machine using my Python2.7 interpreter: https://github.com/danielfrg/word2vec

I've tried downloading the zip & running python setup.py install from the unzipped directory and running pip install. however in both instances it returns the below errors:

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

There seemed to be a problem accessing subprocess.call(), so after a bit of googling I managed to add shell=True to the line the the word2vec setup.py and it then throws this error:

'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 

To be honest I'm not even sure where I should go from here. I've also tried installing make and setting the path variable to the .exe file in the install, any advice would be greatly appreciated, thanks.

UPDATE:

While the word2vec module wouldn't work a package called genism seems to work pretty well, it's got some great other NLP functionality too http://radimrehurek.com/gensim/

Keet Sugathadasa
  • 11,595
  • 6
  • 65
  • 80
pygeorgiou
  • 115
  • 1
  • 1
  • 5

6 Answers6

16

The word2vec is meant for Linux. See: https://github.com/danielfrg/word2vec

At the bottom it says there is a very experimental Windows build at: support:https://github.com/zhangyafeikimi/word2vec-win32

EDIT:

Looks like you can also install gensim: https://pypi.python.org/pypi/gensim

Then do:

from gensim.models import word2vec
William Ross
  • 3,568
  • 7
  • 42
  • 73
  • Note that now 7+ years later, you shouldn't have to rely on any experimental or outside-usual-package-repo builds... if your virtual environment's Python interpreter is a well-supported version, major repos like PyPI or those backing `conda` are likely to have prebuilt working Windows wheels for Gensim. – gojomo Apr 05 '23 at 18:35
3

For me this approach worked on Win 7 and Win 8 both.

  1. Install Anaconda 64-bit (Python version 2.7)
  2. Install MinGW Basic compiler (make sure to select C and C++ compilers in the installation list)
  3. Re-install gensim on Anaconda using the command "conda install gensim" Then you can open the ipython-notebook and try running python code using word2vec, it should work.
  • As noted in @WilliamRoss's answer, to run word2vec from gensim, you need to `from gensim.models import word2vec` – drevicko Jun 18 '16 at 12:49
1

Using pip to install python libraries is a good approach.

1. Install pip

A) Start a command prompt as an administrator

  1. Click Start, click All Programs, and then click Accessories.

  2. Right-click Command prompt, and then click Run as administrator.

  3. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.

B) Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt.

python get-pip.py

Download get-pip.py, and save it as a get-pip.py(not get-pip.txt).

Run it from the command prompt.

python get-pip.py

2. Install word2vec

Now you can install it with

pip install word2vec
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
0

Looks like this package contains C code and calls a UN*X makefile, so it has not been written for Windows. You could try to find a precompiled Windows binary.

  • Thanks, i didn't' think of that. I've used this site before. but doesn't look like they have it http://www.lfd.uci.edu/~gohlke/pythonlibs/ do you know anywhere else? – pygeorgiou Sep 03 '14 at 15:33
  • Marked as the correct answer as it is, however there isn't a precompiled binary for the word2vec module unfortunately. I have found a solution which I'll post as an update in the question – pygeorgiou Sep 15 '14 at 13:04
0

I was able to successfully compile and run the original word2vec code (https://github.com/dav/word2vec) on Windows using Cygwin. That said, I like the gensim package better anyway - it has no problem with UTF-8, whereas the original code chokes on non-ASCII characters.

Gabriel
  • 587
  • 5
  • 17
0

word2vec comes in scipy version 1.2.0 and mostly scipy verion installed is 1.1

For anaconda you need to download Scipy using this commond conda install -c anaconda scipy

This will install you current scipy version...

Then you need to install gensim by using this commond conda install -c conda-forge gensim

I hope this will hep you...

Anshul Singh Suryan
  • 878
  • 1
  • 11
  • 15