Ubuntu环境下安装word2vec的一些坑

Content

  • Ubuntu环境下安装word2vec的一些坑
    • 报错
    • 解决方法

Ubuntu环境下安装word2vec的一些坑

最近在尝试使用Linux写python程序,其中需要做一些关于NLP方面的处理,要安装word2vec包,但是一直在出问题

报错

一种最主要的错误

ERROR: Could not build wheels for word2vec which use PEP 517

然后网上查了很多方法都没有作用,比如说

sudo apt-get install protobuf-compiler libprotoc-dev
pip install onnx

然后安装后运行

python -c "import onnx"

没有用
接下来我往上翻报错的信息,发现有一个gcc无法找到的问题

error: [Errno 2] No such file or directory: 'gcc': 'gcc'

原来这个才是关键的地方

解决方法

这是缺少c++编译器
安装一个就完事了
在Linux命令行下面运行

sudo apt-get  install  build-essential

接下来查看是否安装成功

cc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

最后pip安装即可

pip install word2vec
Collecting word2vec
  Using cached https://files.pythonhosted.org/packages/11/9e/dc6d96578191b6167cb1ea4a3fe3edeed0dce54d3db21ada013b2b407d65/word2vec-0.11.1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
......
Successfully built word2vec
Installing collected packages: word2vec
Successfully installed word2vec-0.11.1

大功告成

你可能感兴趣的:(Linux填坑记,ubuntu,linux,python)