codelucas / newspaper

newspaper3k is a news, full-text, and article metadata extraction in Python 3. Advanced docs:
https://goo.gl/VX41yK
MIT License
14.06k stars 2.11k forks source link

python2.7 install from pip won't run #242

Closed manuel-delverme closed 8 years ago

manuel-delverme commented 8 years ago

root@Ubuntu-1604-xenial-64-minimal /home/user # pip install --upgrade newspaper

Requirement already up-to-date: newspaper in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: Pillow==2.5.1 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: tldextract==1.5.1 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: python-dateutil==2.4.0 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: cssselect==0.9.1 in /usr/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: feedfinder2==0.0.1 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: six==1.7.3 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: beautifulsoup4==4.3.2 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: feedparser==5.1.3 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: nltk==2.0.5 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: requests==2.3.0 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: jieba==0.35 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: lxml==3.3.5 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: PyYAML==3.11 in /usr/local/lib/python2.7/dist-packages (from newspaper)
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages (from tldextract==1.5.1->newspaper)

root@Ubuntu-1604-xenial-64-minimal /home/user # ipython

Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import newspaper

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-3d891fe45a25> in <module>()
----> 1 import newspaper

/usr/local/lib/python2.7/dist-packages/newspaper3k-0.1.7-py2.7.egg/newspaper/__init__.py in <module>()
      8 __copyright__ = 'Copyright 2014, Lucas Ou-Yang'
      9 
---> 10 from .article import Article, ArticleException
     11 from .api import (build, build_article, fulltext, hot, languages,
     12                   popular_urls, NewsPool, Configuration as Config)

/usr/local/lib/python2.7/dist-packages/newspaper3k-0.1.7-py2.7.egg/newspaper/article.py in <module>()
     10 import glob
     11 
---> 12 from . import images
     13 from . import network
     14 from . import nlp

/usr/local/lib/python2.7/dist-packages/newspaper3k-0.1.7-py2.7.egg/newspaper/images.py in <module>()
     13 import io
     14 import traceback
---> 15 import urllib.parse
     16 
     17 import requests

ImportError: No module named parse

In [2]: 
yprez commented 8 years ago

Looks like you somehow ended up with the Python3 version, look at the path:

/usr/local/lib/python2.7/dist-packages/newspaper3k-0.1.7-py2.7.egg/newspaper/ - it looks like the newspaper3k package, not the python2 compatible version.

Can you try:

pip uninstall newspaper3k
pip install newspaper --upgrade

?

manuel-delverme commented 8 years ago

In [1]: import newspaper

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-3d891fe45a25> in <module>()
----> 1 import newspaper

/usr/local/lib/python2.7/dist-packages/newspaper/__init__.py in <module>()
      8 __copyright__ = 'Copyright 2014, Lucas Ou-Yang'
      9 
---> 10 from .article import Article, ArticleException
     11 from .api import (build, build_article, fulltext, hot, languages,
     12                   popular_urls, NewsPool, Configuration as Config)

/usr/local/lib/python2.7/dist-packages/newspaper/article.py in <module>()
     11 
     12 from . import images
---> 13 from . import network
     14 from . import nlp
     15 from . import settings

/usr/local/lib/python2.7/dist-packages/newspaper/network.py in <module>()
     10 
     11 import logging
---> 12 import requests
     13 
     14 from .configuration import Configuration

/usr/local/lib/python2.7/dist-packages/requests/__init__.py in <module>()
     51 # Attempt to enable urllib3's SNI support, if possible
     52 try:
---> 53     from .packages.urllib3.contrib import pyopenssl
     54     pyopenssl.inject_into_urllib3()
     55 except ImportError:

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py in <module>()
     68 _openssl_versions = {
     69     ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
---> 70     ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,
     71     ssl.PROTOCOL_TLSv1: OpenSSL.SSL.TLSv1_METHOD,
     72 }

AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'
yprez commented 8 years ago

Can you post the output of pip freeze?

manuel-delverme commented 8 years ago
attrs==15.2.0
BeautifulSoup==3.2.1
beautifulsoup4==4.3.2
boto==2.38.0
cffi==1.6.0
chardet==2.3.0
cryptography==1.2.3
cssselect==0.9.1
decorator==4.0.6
Django==1.8.7
enum34==1.1.4
feedfinder2==0.0.1
feedparser==5.1.3
html5lib==0.999
idna==2.1
ipaddress==1.0.16
ipython==2.4.1
jieba==0.35
jieba3k==0.35.1
lxml==3.3.5
mysqlclient==1.3.7
ndg-httpsclient==0.4.0
newspaper==0.0.9.8
nltk==2.0.5
PAM==0.4.2
pexpect==4.0.1
Pillow==2.5.1
ptyprocess==0.5
pyasn1==0.1.9
pyasn1-modules==0.0.7
pycparser==2.14
pycrypto==2.6.1
Pygments==2.1
pyOpenSSL==0.15.1
pyserial==3.0.1
python-dateutil==2.4.0
pytz==2014.10
PyYAML==3.11
queuelib==1.4.2
requests==2.3.0
requests-file==1.4
Scrapy==1.0.3
service-identity==16.0.0
simplegeneric==0.8.1
six==1.10.0
sqlparse==0.1.18
tldextract==1.5.1
Twisted==16.0.0
urllib3==1.13.1
virtualenv==15.0.1
w3lib==1.13.0
zope.interface==4.1.3
yprez commented 8 years ago

Maybe try installing a new version of requests:

pip install requests -U

if this doesn't work I have no idea what the problem is.

manuel-delverme commented 8 years ago

Requirement already up-to-date: requests in /usr/local/lib/python2.7/dist-packages

manuel-delverme commented 8 years ago

installed httpie and jupyter, now it works but it's black magic to me

new freeze > https://clbin.com/7IMbC

close the issue if you feel like

yprez commented 8 years ago

really weird... but if it works I guess it's ok (until it comes up again)