1

I am installing Python newspaper library with the following command in a virtual environment:

pip install newspaper

I get the following error. It still exists after I tried a few solutions from StackOverflow but it didn't work. I had the same issue before which I resolved with installing a specific version(and updating) of setup tools (different machine). However, it doesn't work here.

Any ideas what am I doing wrong? What does this error actually mean?

IDE: Pycharm with a virtual environment, Python 2.7 on Ubuntu

Error:

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/
utengr
  • 3,225
  • 3
  • 29
  • 68

3 Answers3

1

According to newspaper's Github documentation page, they have deprecated the Python 2 version of the API and have termed it as buggy. The exact statement as follows:

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

Reference: https://github.com/codelucas/newspaper

It shows that we should not use the Python 2 version anymore.

For now, I switched to Python 3 for this specific use case.

utengr
  • 3,225
  • 3
  • 29
  • 68
0

Try reinstall setuptools

pip install --upgrade setuptools

if not work, remove distribute:

rm -fr /usr/local/lib/python2.7/dist-packages/distribute*
Flavio Milan
  • 467
  • 3
  • 16
  • You use Linux or Windows? – Flavio Milan Jul 17 '17 at 11:37
  • Even I encountered the same problem when trying to install newspaper today. However upgrading setuptools as suggested by Flavio helped me resolve this issue but then hit another issue around the lines of "lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h: No such file or directory", but was able to solve it by installing these packages - apt-get install libxml2-dev libxslt-dev. Even I am on Ubuntu 16.04. Are you hitting other errors or still stuck on your first error? – Amarnath Revanna Jul 18 '17 at 13:44
  • try: apt-get install libxmlsec1-dev – Flavio Milan Jul 18 '17 at 15:51
  • @FlavioMilan have tried that. I actually tried what was available online in terms of solutions. I also followed correctly the newspaper installation but it's not helping. I suspect something is wrong with my setup tools version but can figure it out. – utengr Jul 19 '17 at 12:29
  • none of these works. I tried before a specific version of setup tools which solved the problem. But it was some time ago so don't remember anymore. – utengr Jul 19 '17 at 12:35
  • @AmarnathRevanna their Python 2 version is just buggy and they have stopped working on it. It's mainly available for Python 3. See my answer below. – utengr Sep 29 '17 at 10:52
-2

can confirm that this

pip install --upgrade setuptools

cleared up the installation issue on ec2

JMK
  • 1