roy-ht / editdistance

Fast implementation of the edit distance(Levenshtein distance)
MIT License
661 stars 62 forks source link

Cannot install editdistance #49

Closed sapphire008 closed 3 years ago

sapphire008 commented 3 years ago

I am trying to install editdistance via pip install editdistance on Windows 10 and received the following error:

 Running setup.py clean for editdistance
Failed to build editdistance
Installing collected packages: editdistance
    Running setup.py install for editdistance ... error
    ERROR: Command errored out with exit status 1:
     command: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Edward\\AppData\\Local\\Temp\\pip-install-fr81oa59\\editdistance\\setup.py'"'"'; __file__='"'"'C:\\Users\\Edward\\AppData\\Local\\Temp\\pip-install-fr81oa59\\editdistance\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Edward\AppData\Local\Temp\pip-record-57_cziv1\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda3\Include\editdistance'
         cwd: C:\Users\Edward\AppData\Local\Temp\pip-install-fr81oa59\editdistance\
    Complete output (31 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    creating build\lib.win-amd64-3.8\editdistance
    copying editdistance\__init__.py -> build\lib.win-amd64-3.8\editdistance
    copying editdistance\_editdistance.h -> build\lib.win-amd64-3.8\editdistance
    copying editdistance\def.h -> build\lib.win-amd64-3.8\editdistance
    running build_ext
    building 'editdistance.bycython' extension
    creating build\temp.win-amd64-3.8
    creating build\temp.win-amd64-3.8\Release
    creating build\temp.win-amd64-3.8\Release\editdistance
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I./editdistance -ID:\Anaconda3\include -ID:\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29333\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpeditdistance/_editdistance.cpp /Fobuild\temp.win-amd64-3.8\Release\editdistance/_editdistance.obj
    _editdistance.cpp
    editdistance/_editdistance.cpp(1): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
    editdistance/_editdistance.cpp(117): error C2059: syntax error: 'if'
    editdistance/_editdistance.cpp(118): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(119): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(120): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(121): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(122): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(123): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(124): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(125): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(126): error C2059: syntax error: 'else'
    editdistance/_editdistance.cpp(127): error C2059: syntax error: 'return'
    editdistance/_editdistance.cpp(128): error C2059: syntax error: '}'
    editdistance/_editdistance.cpp(128): error C2143: syntax error: missing ';' before '}'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Edward\\AppData\\Local\\Temp\\pip-install-fr81oa59\\editdistance\\setup.py'"'"'; __file__='"'"'C:\\Users\\Edward\\AppData\\Local\\Temp\\pip-install-fr81oa59\\editdistance\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Edward\AppData\Local\Temp\pip-record-57_cziv1\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\Anaconda3\Include\editdistance' Check the logs for full command output.

I believe this is caused by the non-unicode characters in the _editdistance/_editdistance.cpp file, as the message suggested.

Outerskyb commented 3 years ago

I had same problem. install it with conda works for me.