同事给了网址 https://github.com/facebookresearch/fastText ,想安装测试也一下
下载zip包,解压,进入fastText-master目录下进CMD命令行执行python setup.py install
报错:Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
下载Microsoft Visual C++ 2017 Redistributable (x64) - 14.13.26020装上还是提示这个。根据v2ex上的帮助安装了根据stackoverflow上的帮助下载Visual Studio Community 2017安装,打开Visual Studio Installer,选pip install pycryptodome
、pip install --upgrade setuptools
依旧无效使用C++的桌面开发
,右侧摘要
里面,关闭其他项,只选勾上用于桌面的 VC++ 2015.3 v140工具集(x86, x64)
安装。终于过了。
然后报错:ModuleNotFoundError: No module named 'pybind11'
这个文档里面有提到的,安装python install pybind11
。安装完成提示:
Requirement already satisfied: pybind11 in c:\users\l\anaconda3\lib\site-packages (2.3.dev0) notebook 5.4.0 requires ipykernel, which is not installed. jupyter 1.0.0 requires ipykernel, which is not installed. jupyter-console 5.2.0 requires ipykernel, which is not installed. ipywidgets 7.1.1 requires ipykernel>=4.5.1, which is not installed.
继续安装pip install ipykernel
顺便提一下,我的python用的是Anaconda,估计省去了安装NumPy & SciPy的问题。
再来安装fastText,继续报错:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\crtdefs.h(10): fatal error C1083: 无法打开包括文件: “corecrt.h”: No such file or directoryerror: command 'C:\Program Files(x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2
根据csdn上的帮助,还是打开Visual Studio Installer,点击修改,选使用C++的桌面开发
,右侧摘要
里面,勾选Windows 10 SDK (10.0.14393.0)
,挑了个最新的win10 SDK安装。网上的意思是win10 SDK目前并不是向下兼容的,为了以后着想还是用最新的吧,如果有问题,再装旧的进行测试。
fastText-master>python setup.py install
running install
running bdist_egg
running egg_info
writing python\fasttext.egg-info\PKG-INFO
writing dependency_links to python\fasttext.egg-info\dependency_links.txt
writing requirements to python\fasttext.egg-info\requires.txt
writing top-level names to python\fasttext.egg-info\top_level.txt
reading manifest file 'python\fasttext.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'python\fasttext.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
building 'fasttext_pybind' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tppython/fastTe
xt/pybind/fasttext_pybind.cc /Fobuild\temp.win-amd64-3.6\Release\python/fastText
/pybind/fasttext_pybind.obj /EHsc /DVERSION_INFO=\"0.8.22\"
fasttext_pybind.cc
c:\users\l\anaconda3\lib\fasttext-master\src\productquantizer.h(31): warning C43
05: “初始化”: 从“double”到“const fasttext::real”截断
python/fastText/pybind/fasttext_pybind.cc(49): warning C4996: 'sscanf': This fun
ction or variable may be unsafe. Consider using sscanf_s instead. To disable dep
recation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\stdio.h(2254):
note: 参见“sscanf”的声明
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\args.cc /
Fobuild\temp.win-amd64-3.6\Release\src\args.obj /EHsc /DVERSION_INFO=\"0.8.22\"
args.cc
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\dictionar
y.cc /Fobuild\temp.win-amd64-3.6\Release\src\dictionary.obj /EHsc /DVERSION_INFO
=\"0.8.22\"
dictionary.cc
src\dictionary.cc(41): warning C4267: “初始化”: 从“size_t”转换到“int32_t”
,可能丢失数据
src\dictionary.cc(194): warning C4267: “参数”: 从“size_t”转换到“const int”
,可能丢失数据
src\dictionary.cc(281): warning C4244: “=”: 从“double”转换到“float”,可能
丢失数据
src\dictionary.cc(344): warning C4244: “参数”: 从“double”转换到“fasttext::r
eal”,可能丢失数据
src\dictionary.cc(447): warning C4244: “初始化”: 从“double”转换到“int32_t”
,可能丢失数据
src\dictionary.cc(488): warning C4267: “=”: 从“size_t”转换到“int32_t”,可
能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\fasttext.
cc /Fobuild\temp.win-amd64-3.6\Release\src\fasttext.obj /EHsc /DVERSION_INFO=\"0
.8.22\"
fasttext.cc
c:\users\l\anaconda3\lib\fasttext-master\src\productquantizer.h(31): warning C43
05: “初始化”: 从“double”到“const fasttext::real”截断
src\fasttext.cc(70): warning C4244: “参数”: 从“double”转换到“fasttext::real
”,可能丢失数据
src\fasttext.cc(251): warning C4244: “初始化”: 从“int64_t”转换到“int32_t”
,可能丢失数据
src\fasttext.cc(288): warning C4018: “<”: 有符号/无符号不匹配
src\fasttext.cc(289): warning C4267: “参数”: 从“size_t”转换到“int32_t”,可
能丢失数据
src\fasttext.cc(331): warning C4267: “参数”: 从“size_t”转换到“int”,可能丢
失数据
src\fasttext.cc(386): warning C4267: “+=”: 从“size_t”转换到“int32_t”,可能
丢失数据
src\fasttext.cc(387): warning C4267: “+=”: 从“size_t”转换到“int32_t”,可能
丢失数据
src\fasttext.cc(452): warning C4244: “参数”: 从“double”转换到“fasttext::rea
l”,可能丢失数据
src\fasttext.cc(465): warning C4244: “参数”: 从“double”转换到“fasttext::rea
l”,可能丢失数据
src\fasttext.cc(471): warning C4244: “参数”: 从“double”转换到“fasttext::rea
l”,可能丢失数据
src\fasttext.cc(502): warning C4244: “参数”: 从“double”转换到“fasttext::rea
l”,可能丢失数据
src\fasttext.cc(584): warning C4244: “初始化”: 从“double”转换到“fasttext::r
eal”,可能丢失数据
src\fasttext.cc(622): warning C4018: “<”: 有符号/无符号不匹配
src\fasttext.cc(627): warning C4018: “<”: 有符号/无符号不匹配
src\fasttext.cc(636): warning C4244: “参数”: 从“double”转换到“fasttext::rea
l”,可能丢失数据
src\fasttext.cc(638): warning C4018: “<”: 有符号/无符号不匹配
src\fasttext.cc(641): warning C4018: “<”: 有符号/无符号不匹配
src\fasttext.cc(666): warning C4244: “参数”: 从“double”转换到“fasttext::rea
l”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\memory(901): warn
ing C4267: “参数”: 从“size_t”转换到“int32_t”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\memory(971): note
: 参见对正在编译的函数 模板 实例化“std::_Ref_count_obj<_Ty>::_Ref_count_obj(fasttext::Matrix &,const size_t &,cons
t bool &)”的引用
with
[
_Ty=fasttext::QMatrix
]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\memory(971): note
: 参见对正在编译的函数 模板 实例化“std::_Ref_count_obj<_Ty>::_Ref_count_obj(fasttext::Matrix &,const size_t &,cons
t bool &)”的引用
with
[
_Ty=fasttext::QMatrix
]
src\fasttext.cc(308): note: 参见对正在编译的函数 模板 实例化“std::shared_ptr std::make_shared(_Ty &,const size_t &,const bool &)”的引用
with
[
_Ty=fasttext::Matrix
]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\main.cc /
Fobuild\temp.win-amd64-3.6\Release\src\main.obj /EHsc /DVERSION_INFO=\"0.8.22\"
main.cc
c:\users\l\anaconda3\lib\fasttext-master\src\productquantizer.h(31): warning C43
05: “初始化”: 从“double”到“const fasttext::real”截断
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\matrix.cc
/Fobuild\temp.win-amd64-3.6\Release\src\matrix.obj /EHsc /DVERSION_INFO=\"0.8.2
2\"
matrix.cc
src\matrix.cc(33): warning C4244: “=”: 从“double”转换到“float”,可能丢失数
据
src\matrix.cc(98): warning C4244: “return”: 从“double”转换到“fasttext::real
”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xutility(2766): w
arning C4244: “=”: 从“const double”转换到“float”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xutility(2780): n
ote: 参见对正在编译的函数 模板 实例化“void std::_Fill_unchecked1<_FwdIt,_Ty>(_F
wdIt,_FwdIt,const _Ty &,std::false_type)”的引用
with
[
_FwdIt=float *,
_Ty=double
]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xutility(2788): n
ote: 参见对正在编译的函数 模板 实例化“void std::_Fill_unchecked(_Fw
dIt,_FwdIt,const _Ty &)”的引用
with
[
_Ty=double,
_FwdIt=float *
]
src\matrix.cc(26): note: 参见对正在编译的函数 模板 实例化“void std::fill>>,double>(_FwdIt,_Fwd
It,const _Ty &)”的引用
with
[
_FwdIt=std::_Vector_iterator>>,
_Ty=double
]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\model.cc
/Fobuild\temp.win-amd64-3.6\Release\src\model.obj /EHsc /DVERSION_INFO=\"0.8.22\
"
model.cc
c:\users\l\anaconda3\lib\fasttext-master\src\productquantizer.h(31): warning C43
05: “初始化”: 从“double”到“const fasttext::real”截断
src\model.cc(36): warning C4244: “=”: 从“int64_t”转换到“int32_t”,可能丢失
数据
src\model.cc(52): warning C4244: “=”: 从“int64_t”转换到“int32_t”,可能丢失
数据
src\model.cc(64): warning C4244: “参数”: 从“double”转换到“fasttext::real”
,可能丢失数据
src\model.cc(119): warning C4244: “初始化”: 从“double”转换到“fasttext::real
”,可能丢失数据
src\model.cc(137): warning C4244: “参数”: 从“double”转换到“fasttext::real”
,可能丢失数据
src\model.cc(218): warning C4244: “=”: 从“double”转换到“fasttext::real”,
可能丢失数据
src\model.cc(220): warning C4244: “参数”: 从“double”转换到“fasttext::real”
,可能丢失数据
src\model.cc(239): warning C4244: “参数”: 从“double”转换到“fasttext::real”
,可能丢失数据
src\model.cc(259): warning C4244: “+=”: 从“double”转换到“fasttext::real”,
可能丢失数据
src\model.cc(262): warning C4244: “初始化”: 从“double”转换到“fasttext::real
”,可能丢失数据
src\model.cc(264): warning C4267: “参数”: 从“size_t”转换到“const int”,可
能丢失数据
src\model.cc(285): warning C4244: “=”: 从“double”转换到“int64_t”,可能丢失
数据
src\model.cc(330): warning C4244: “参数”: 从“double”转换到“float”,可能丢
失数据
src\model.cc(336): warning C4244: “初始化”: 从“double”转换到“fasttext::real
”,可能丢失数据
src\model.cc(350): warning C4244: “return”: 从“double”转换到“fasttext::real
”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Iinclude -Iinclude -Isrc -IC:\Users\L\Anaconda3
\include -IC:\Users\L\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visu
al Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.
0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.1439
3.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared"
"-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpsrc\productqu
antizer.cc /Fobuild\temp.win-amd64-3.6\Release\src\productquantizer.obj /EHsc /D
VERSION_INFO=\"0.8.22\"
productquantizer.cc
c:\users\l\anaconda3\lib\fasttext-master\src\productquantizer.h(31): warning C43
05: “初始化”: 从“double”到“const fasttext::real”截断
src\productquantizer.cc(132): error C2039: “to_string”: 不是“std”的成员
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\numeric(12): note
: 参见“std”的声明
src\productquantizer.cc(132): error C3861: “to_string”: 找不到标识符
src\productquantizer.cc(132): error C2512: “std::invalid_argument”: 没有合适的
默认构造函数可用
src\productquantizer.cc(132): note: 无构造函数可以接受源类型,或构造函数重载决策
不明确
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\
x86_amd64\\cl.exe' failed with exit status 2
已经失去耐心的情况下,直接pip search fasttext
发现居然就有现成的fasttext!!!可以直接安装pip install fasttext
ok
之前的记录算是踩坑吧,如果帮到其他其他人,就算没白写。
至于无法通过setup.py安装问题,有人懂的可以留言。如果也不懂的,建议直接pip安装吧