windows10下用pip安装fastText和cysignals报错系统找不到指定的文件

背景

在运行知识图谱相关demo时,需要安装fastText,安装fastText又要安装cysignals,但安装时报错系统找不到文件,具体如下:

    ERROR: Command errored out with exit status 1:
     command: 'd:\develop\python\python36\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-oyvldc2g\\pyfasttext\\setup.py'"'"'; __file__='"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-oyvldc2g\\pyfasttext\\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 pip-egg-info
         cwd: C:\Users\SONGZE~1\AppData\Local\Temp\pip-install-oyvldc2g\pyfasttext\
    Complete output (42 lines):
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Collecting cysignals
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/51/5f/727aa099de5c60b3fb42cdde72097277803dabe78b177afdb5b835bbf909/cysignals-1.10.2.tar.gz (95kB)
    Requirement already satisfied: Cython>=0.28 in d:\develop\python\python36\lib\site-packages (from cysignals) (0.29.13)
    Building wheels for collected packages: cysignals
      Building wheel for cysignals (setup.py): started
      Building wheel for cysignals (setup.py): finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: 'd:\develop\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-tbk9jfyy\\cysignals\\setup.py'"'"'; __file__='"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-tbk9jfyy\\cysignals\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\SONGZE~1\AppData\Local\Temp\pip-wheel-bspvc9ol' --python-tag cp36
           cwd: C:\Users\SONGZE~1\AppData\Local\Temp\pip-install-tbk9jfyy\cysignals\
      Complete output (3 lines):
      running bdist_wheel
      running build
      error: [WinError 2] 系统找不到指定的文件。
      ----------------------------------------
      ERROR: Failed building wheel for cysignals
      Running setup.py clean for cysignals
    Failed to build cysignals
    Installing collected packages: cysignals
      Running setup.py install for cysignals: started
        Running setup.py install for cysignals: finished with status 'error'
        ERROR: Command errored out with exit status 1:
         command: 'd:\develop\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-tbk9jfyy\\cysignals\\setup.py'"'"'; __file__='"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-tbk9jfyy\\cysignals\\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\SONGZE~1\AppData\Local\Temp\pip-record-66u13zhc\install-record.txt' --single-version-externally-managed --compile
             cwd: C:\Users\SONGZE~1\AppData\Local\Temp\pip-install-tbk9jfyy\cysignals\
        Complete output (3 lines):
        running install
        running build
        error: [WinError 2] 系统找不到指定的文件。
        ----------------------------------------
    ERROR: Command errored out with exit status 1: 'd:\develop\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-tbk9jfyy\\cysignals\\setup.py'"'"'; __file__='"'"'C:\\Users\\SONGZE~1\\AppData\\Local\\Temp\\pip-install-tbk9jfyy\\cysignals\\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\SONGZE~1\AppData\Local\Temp\pip-record-66u13zhc\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
    Traceback (most recent call last):
      File "C:\Users\SONGZE~1\AppData\Local\Temp\pip-install-oyvldc2g\pyfasttext\setup.py", line 33, in 
        import cysignals
    ModuleNotFoundError: No module named 'cysignals'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "", line 1, in 
      File "C:\Users\SONGZE~1\AppData\Local\Temp\pip-install-oyvldc2g\pyfasttext\setup.py", line 37, in 
        raise RuntimeError('cannot install cysignals with pip')
    RuntimeError: cannot install cysignals with pip
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方法

只能通过源码安装的方式安装fastText了,步骤如下

pip安装pybind11

这是个fasttext源码安装的必备组件

pip install pybind11

安装visual studio

我选的版本是2015,可以用

下载解压fastText源码

源码地址https://github.com/xiamx/fastText/releases,直接下载Source Code(zip)

运行setup.py

打开cmd,切到源码根目录,运行setup.py,静候其完成。

 python setup.py install

结语

参考文章https://blog.csdn.net/m0_37870649/article/details/80935307

你可能感兴趣的:(杂记)