【问题标题】:issue with installing python newspaper package安装python报纸包的问题
【发布时间】:2017-07-17 11:28:59
【问题描述】:

我正在虚拟环境中使用以下命令安装 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/

【问题讨论】:

    标签: python pycharm nltk python-newspaper


    【解决方案1】:

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

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

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

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

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

    【讨论】:

      【解决方案2】:

      尝试重新安装 setuptools

      pip install --upgrade setuptools
      

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

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

      【讨论】:

      • 您使用 Linux 还是 Windows?
      • 即使我今天在尝试安装报纸时也遇到了同样的问题。然而,按照 Flavio 的建议升级 setuptools 帮助我解决了这个问题,但随后又遇到了另一个问题,即“lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory”,但能够通过安装这些软件包来解决它 - apt-get install libxml2-dev libxslt-dev。即使我在 Ubuntu 16.04 上。您是否遇到其他错误或仍然停留在第一个错误?
      • 尝试:apt-get install libxmlsec1-dev
      • @FlavioMilan 已经尝试过了。我实际上尝试了在线可用的解决方案。我也正确地遵循了报纸的安装,但这没有帮助。我怀疑我的设置工具版本有问题,但可以解决。
      • 这些都不起作用。我在解决问题的特定版本的设置工具之前尝试过。不过是很久以前的事了,不记得了。
      【解决方案3】:

      可以确认这个

      pip install --upgrade setuptools

      解决了 ec2 上的安装问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-19
        • 2013-09-14
        • 2018-08-14
        • 2015-03-18
        • 2014-09-02
        • 2021-08-23
        相关资源
        最近更新 更多