maciejkula / glove-python

Toy Python implementation of http://www-nlp.stanford.edu/projects/glove/
Apache License 2.0
1.25k stars 319 forks source link

unable install on win10 #111

Closed cdhx closed 4 years ago

cdhx commented 4 years ago

C:\Users\pc\Desktop\glove_python-0.1.0>python setup.py install running install running bdist_egg running egg_info writing glove_python.egg-info\PKG-INFO writing dependency_links to glove_python.egg-info\dependency_links.txt writing requirements to glove_python.egg-info\requires.txt writing top-level names to glove_python.egg-info\top_level.txt reading manifest file 'glove_python.egg-info\SOURCES.txt' writing manifest file 'glove_python.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py running build_ext building 'glove.glove_cython' extension D:\Dev-Cpp\MinGW64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -IC:\Users\pc\Anaconda3\include -IC:\Users\pc\Anaconda3\include -c glove/glove_cython.c -o build\temp.win-amd64-3.7\Release\glove\glove_cython.o -fopenmp -ffast-math -march=native glove/glove_cython.c: In function 'Pyx_ExceptionSave': glove/glove_cython.c:16753:19: error: 'PyThreadState' has no member named 'exc_type' type = tstate->exc_type; ^ glove/glove_cython.c:16754:20: error: 'PyThreadState' has no member named 'exc_value' value = tstate->exc_value; ^ glove/glove_cython.c:16755:17: error: 'PyThreadState' has no member named 'exc_traceback' *tb = tstate->exc_traceback; ^ glove/glove_cython.c: In function '__Pyx_ExceptionReset': glove/glove_cython.c:16767:22: error: 'PyThreadState' has no member named 'exc_type' tmp_type = tstate->exc_type; ^ glove/glove_cython.c:16768:23: error: 'PyThreadState' has no member named 'exc_value' tmp_value = tstate->exc_value; ^ glove/glove_cython.c:16769:20: error: 'PyThreadState' has no member named 'exc_traceback' tmp_tb = tstate->exc_traceback; ^ glove/glove_cython.c:16770:11: error: 'PyThreadState' has no member named 'exc_type' tstate->exc_type = type; ^ glove/glove_cython.c:16771:11: error: 'PyThreadState' has no member named 'exc_value' tstate->exc_value = value; ^ glove/glove_cython.c:16772:11: error: 'PyThreadState' has no member named 'exc_traceback' tstate->exc_traceback = tb; ^ glove/glove_cython.c: In function 'Pyx_GetException': glove/glove_cython.c:16815:22: error: 'PyThreadState' has no member named 'exc_type' tmp_type = tstate->exc_type; ^ glove/glove_cython.c:16816:23: error: 'PyThreadState' has no member named 'exc_value' tmp_value = tstate->exc_value; ^ glove/glove_cython.c:16817:20: error: 'PyThreadState' has no member named 'exc_traceback' tmp_tb = tstate->exc_traceback; ^ glove/glove_cython.c:16818:11: error: 'PyThreadState' has no member named 'exc_type' tstate->exc_type = local_type; ^ glove/glove_cython.c:16819:11: error: 'PyThreadState' has no member named 'exc_value' tstate->exc_value = local_value; ^ glove/glove_cython.c:16820:11: error: 'PyThreadState' has no member named 'exc_traceback' tstate->exc_traceback = local_tb; ^ glove/glove_cython.c: In function '__Pyx_ExceptionSwap': glove/glove_cython.c:16842:22: error: 'PyThreadState' has no member named 'exc_type' tmp_type = tstate->exc_type; ^ glove/glove_cython.c:16843:23: error: 'PyThreadState' has no member named 'exc_value' tmp_value = tstate->exc_value; ^ glove/glove_cython.c:16844:20: error: 'PyThreadState' has no member named 'exc_traceback' tmp_tb = tstate->exc_traceback; ^ glove/glove_cython.c:16845:11: error: 'PyThreadState' has no member named 'exc_type' tstate->exc_type = type; ^ glove/glove_cython.c:16846:11: error: 'PyThreadState' has no member named 'exc_value' tstate->exc_value = value; ^ glove/glove_cython.c:16847:11: error: 'PyThreadState' has no member named 'exc_traceback' tstate->exc_traceback = *tb; ^ error: command 'D:\Dev-Cpp\MinGW64\bin\gcc.exe' failed with exit status 1

cdhx commented 4 years ago

how to slove this error? and i have installed cpython and remove "stdc++" in code

IronFarm commented 4 years ago

@cdhx

  1. Put stdc++ back into the code. It is there for a reason.
  2. Run python setup.py cythonize to regenerate the Cython output files for your version of Python (you'll need to have cython installed)
  3. Run python setup.py install
IronFarm commented 4 years ago

@cdhx Alternatively, download the attached .zip file and install it by running pip install glove_python-0.1.0-cp37-cp37m-win_amd64.zip

glove_python-0.1.0-cp37-cp37m-win_amd64.zip

cdhx commented 4 years ago

@IronFarm thank you for your reply ! i just found it is cython not cpython.

follow your step, still the same error,

and when i run python setup.py cythonize got this waring

another question, avaliable in python3?

G:\毕业设计\code\data\glove_python\glove-python-master>python setup.py cythonize
running cythonize
Compiling glove/corpus_cython.pyx because it depends on C:\Users\pc\Anaconda3\lib\site-packages\Cython\Includes\libcpp\vector.pxd.
[1/1] Cythonizing glove/corpus_cython.pyx
C:\Users\pc\Anaconda3\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: G:\毕业设计\code\data\glove_python\glove-python-master\glove\corpus_cython.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
IronFarm commented 4 years ago

@cdhx that looks good. Can you compile it now?

cdhx commented 4 years ago

@IronFarm python setup.py cythonize works well but when i run python setup.py got the same error as i first ask error: command 'D:\\Dev-Cpp\\MinGW64\\bin\\gcc.exe' failed with exit status 1

IronFarm commented 4 years ago

@cdhx I'll need more output to help diagnose.

For reference, here is my output when I run the command with python 3.6 on Windows:

C:\Users\IronFarm\glove-python> python setup.py build_ext
running build_ext
building 'glove.glove_cython' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\glove
C:\mingw64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -IC:\Miniconda3\envs\glove-py37\include -IC:\Miniconda3\envs\glove-py37\include -c glove/glove_cython.c -o build\temp.win-amd64-3.7\Release\glove\glove_cython.o -fopenmp -ffast-math -march=native
writing build\temp.win-amd64-3.7\Release\glove\glove_cython.cp37-win_amd64.def
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\glove
C:\mingw64\bin\gcc.exe -shared -s build\temp.win-amd64-3.7\Release\glove\glove_cython.o build\temp.win-amd64-3.7\Release\glove\glove_cython.cp37-win_amd64.def -LC:\Miniconda3\envs\glove-py37\libs -LC:\Miniconda3\envs\glove-py37\PCbuild\amd64 -lpython37 -lmsvcr140 -o build\lib.win-amd64-3.7\glove\glove_cython.cp37-win_amd64.pyd -fopenmp
building 'glove.metrics.accuracy_cython' extension
creating build\temp.win-amd64-3.7\Release\glove\metrics
C:\mingw64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -IC:\Miniconda3\envs\glove-py37\include -IC:\Miniconda3\envs\glove-py37\include -c glove/metrics/accuracy_cython.c -o build\temp.win-amd64-3.7\Release\glove\metrics\accuracy_cython.o -fopenmp -ffast-math -march=native
writing build\temp.win-amd64-3.7\Release\glove\metrics\accuracy_cython.cp37-win_amd64.def
creating build\lib.win-amd64-3.7\glove\metrics
C:\mingw64\bin\gcc.exe -shared -s build\temp.win-amd64-3.7\Release\glove\metrics\accuracy_cython.o build\temp.win-amd64-3.7\Release\glove\metrics\accuracy_cython.cp37-win_amd64.def -LC:\Miniconda3\envs\glove-py37\libs -LC:\Miniconda3\envs\glove-py37\PCbuild\amd64 -lpython37 -lmsvcr140 -o build\lib.win-amd64-3.7\glove\metrics\accuracy_cython.cp37-win_amd64.pyd -fopenmp
building 'glove.corpus_cython' extension
C:\mingw64\bin\gcc.exe -mdll -O -Wall -DMS_WIN64 -IC:\Miniconda3\envs\glove-py37\include -IC:\Miniconda3\envs\glove-py37\include -c glove/corpus_cython.cpp -o build\temp.win-amd64-3.7\Release\glove\corpus_cython.o -fopenmp -ffast-math -march=native
glove/corpus_cython.cpp: In function 'void __pyx_f_5glove_13corpus_cython_increment_matrix(__pyx_t_5glove_13corpus_cython_SparseRowMatrix*, int, int, float)':
glove/corpus_cython.cpp:2598:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
     __pyx_t_1 = ((__pyx_v_row >= __pyx_v_mat->indices->size()) != 0);
                   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glove/corpus_cython.cpp:2740:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
   __pyx_t_1 = ((__pyx_v_idx == __pyx_v_row_indices->size()) != 0);
                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glove/corpus_cython.cpp: In function 'int __pyx_f_5glove_13corpus_cython_matrix_nnz(__pyx_t_5glove_13corpus_cython_SparseRowMatrix*)':
glove/corpus_cython.cpp:2931:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
                       ~~~~~~~~~~^~~~~~~~~~~
glove/corpus_cython.cpp: In function 'PyObject* __pyx_f_5glove_13corpus_cython_matrix_to_coo(__pyx_t_5glove_13corpus_cython_SparseRowMatrix*, int)':
glove/corpus_cython.cpp:3200:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
     for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
                          ~~~~~~~~~~~^~~~~~~~~~~~
writing build\temp.win-amd64-3.7\Release\glove\corpus_cython.cp37-win_amd64.def
C:\mingw64\bin\gcc.exe -shared -s build\temp.win-amd64-3.7\Release\glove\corpus_cython.o build\temp.win-amd64-3.7\Release\glove\corpus_cython.cp37-win_amd64.def -LC:\Miniconda3\envs\glove-py37\libs -LC:\Miniconda3\envs\glove-py37\PCbuild\amd64 -lstdc++ -lpython37 -lmsvcr140 -o build\lib.win-amd64-3.7\glove\corpus_cython.cp37-win_amd64.pyd -fopenmp -ffast-math -march=native

There are a few warnings but no errors and the correct output is produced.

raneejoshi commented 4 years ago

Hi @IronFarm , I have the same issue. I tried your suggestions but came back with these error messages:

  1. pip install glove_python-0.1.0-cp37-cp37m-win_amd64.zip
(base) C:\>pip install glove_python-0.1.0-cp37-cp37m-win_amd64.zip
Processing c:\glove_python-0.1.0-cp37-cp37m-win_amd64.zip
    ERROR: Command errored out with exit status 1:
     command: 'c:\anaconda3\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\22663327\\AppData\\Local\\Temp\\pip-req-build-s_5sz2td\\setup.py'"'"'; __file__='"'"'C:\\Users\\22663327\\AppData\\Local\\Temp\\pip-req-build-s_5sz2td\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\22663327\AppData\Local\Temp\pip-pip-egg-info-5qbcr17s'
         cwd: C:\Users\22663327\AppData\Local\Temp\pip-req-build-s_5sz2td\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\anaconda3\lib\tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\22663327\\AppData\\Local\\Temp\\pip-req-build-s_5sz2td\\setup.py'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  1. python setup.py cythonize
(base) C:\glove_python-0.1.0>python setup.py cythonize
running cythonize
Traceback (most recent call last):
  File "setup.py", line 155, in <module>
    ext_modules=define_extensions()
  File "C:\Anaconda3\lib\site-packages\setuptools\__init__.py", line 161, in setup
    return distutils.core.setup(**attrs)
  File "C:\Anaconda3\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Anaconda3\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "setup.py", line 92, in run
    cythonize(define_extensions(cythonize=True))
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 971, in cythonize
    aliases=aliases)
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list
    for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty
    raise ValueError(error_msg)
ValueError: 'glove/glove_cython.pyx' doesn't match any files

Any idea what could be going wrong for me? Thanks!

IronFarm commented 4 years ago

@raneejoshi I've created a pip package which should support a range of Python versions with no compilation necessary. You can install it using the command pip install glove-python-binary.

If that fails, send me the error message (FYI you can surround the error message with three backticks (```like this```) to get better formatting.

raneejoshi commented 4 years ago

@IronFarm Thanks I got it installed with the pip install glove-python-binary. Were there any changes on the Glove() function. Asking for a cooccurrence matrix?

Thanks for the tip too! ;)

bluetyson commented 4 years ago

@IronFarm thanks very much for that, got a test running.

cdhx commented 4 years ago

@IronFarm thanks a lot !

PerseusTrainee commented 5 months ago

building 'glove.glove_cython' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/