1

我在虚拟环境中使用以下命令安装 Python 报纸库:

pip install newspaper

我收到以下错误。在我尝试了 StackOverflow 的一些解决方案后它仍然存在,但它没有用。我遇到了同样的问题,之前我通过安装特定版本(和更新)的安装工具(不同的机器)解决了这个问题。但是,它在这里不起作用。

任何想法我做错了什么?这个错误实际上是什么意思?

IDE:带有虚拟环境的 Pycharm,Ubuntu 上的 Python 2.7

错误:

File "/tmp/tmp4L5_rz/distribute-0.6.21/pkg_resources.py", line 2229, in activate
        self.insert_on(path)
      File "/tmp/tmp4L5_rz/distribute-0.6.21/pkg_resources.py", line 2330, in insert_on
        "with distribute. Found one at %s" % str(self.location))
    ValueError: A 0.7-series setuptools cannot be installed with distribute. Found one at /usr/lib/python2.7/dist-packages
    /tmp/pip-build-LTk2i0/nltk/distribute-0.6.21-py2.7.egg
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-LTk2i0/nltk/setup.py", line 23, in <module>
        distribute_setup.use_setuptools()
      File "/tmp/pip-build-LTk2i0/nltk/distribute_setup.py", line 145, in use_setuptools
        return _do_download(version, download_base, to_dir, download_delay)
      File "/tmp/pip-build-LTk2i0/nltk/distribute_setup.py", line 125, in _do_download
        _build_egg(egg, tarball, to_dir)
      File "/tmp/pip-build-LTk2i0/nltk/distribute_setup.py", line 116, in _build_egg
        raise IOError('Could not build the egg.')
    IOError: Could not build the egg.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-LTk2i0/nltk/
4

3 回答 3

1

根据报纸的 Github 文档页面,他们已经弃用了 Python 2 版本的 API,并将其称为错误。具体说法如下:

"Newspaper is a Python3 library! Or, view our deprecated and buggy Python2 branch"

参考:https ://github.com/codelucas/newspaper

它表明我们不应该再使用 Python 2 版本了。

目前,我针对这个特定用例切换到 Python 3。

于 2017-09-28T11:57:18.650 回答
0

尝试重新安装 setuptools

pip install --upgrade setuptools

如果不起作用,请删除分发:

rm -fr /usr/local/lib/python2.7/dist-packages/distribute*
于 2017-07-17T11:33:37.210 回答
-2

可以确认这

pip install --upgrade setuptools

清除了 ec2 上的安装问题

于 2017-07-30T15:39:02.087 回答