OSError:不是gzip压缩文件(b've')python [英] OSError: Not a gzipped file (b've') python

查看:1525
本文介绍了OSError:不是gzip压缩文件(b've')python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,并且确保其扩展名和名称正确.但是,我仍然得到输出错误,如下所示.

I have the following code and I made sure its extension and name are correct. However, I still get the error outputted as seen below.

我确实看到另一个人在Stack Overflow上问了类似的问题,并且阅读了答案,但没有帮助我.

I did see another person asked a similar question here on Stack Overflow, and read the answer but it did not help me.

无法加载.bin.gz预训练单词2vecx

任何建议如何解决此问题?

Any suggestions how to fix this?

输入:

import gensim
word2vec_path = "GoogleNews-vectors-negative300.bin.gz"
word2vec = gensim.models.KeyedVectors.load_word2vec_format(word2vec_path, binary=True)

输出:

OSError: Not a gzipped file (b've')

推荐答案

问题是您下载的文件不是gzip文件.如果您检查文件的大小,则可能以KB为单位(这是我发生的事情,当我从

The problem is that the file you've downloaded is not a gzip file. If you check the size of the file it maybe in KBs (that is what happened with me, when I downloaded it from this Github link because it needed git-lfs)

以下是解决此问题的另一种方法:

Here is an alternate solution to resolve this issue:

在终端上使用以下命令下载模型:

Download the model using the below command on your terminal:

wget -c "https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz"

然后,像使用gensim一样加载模型:

Then, load the model as you would using gensim:

from gensim import models

w = models.KeyedVectors.load_word2vec_format(
    'GoogleNews-vectors-negative300.bin', binary=True)

希望这对您有帮助!

这篇关于OSError:不是gzip压缩文件(b've')python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆