安装 python newspaper 包的问题

issue with installing python newspaper package

我正在虚拟环境中使用以下命令安装 Python 报纸图书馆:

pip install newspaper

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

知道我做错了什么吗?这个错误究竟意味着什么?

IDE:Pycharm 使用虚拟环境,Python 2.7 on Ubuntu

错误:

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/

尝试重新安装安装工具

pip install --upgrade setuptools

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

rm -fr /usr/local/lib/python2.7/dist-packages/distribute*

可以确认这个

pip install --upgrade setuptools

解决了 ec2 上的安装问题

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

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

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

说明我们不应该再使用Python2版本了。

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