Closed manuel-delverme closed 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
?
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'
Can you post the output of pip freeze
?
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
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.
Requirement already up-to-date: requests in /usr/local/lib/python2.7/dist-packages
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
really weird... but if it works I guess it's ok (until it comes up again)
root@Ubuntu-1604-xenial-64-minimal /home/user # pip install --upgrade newspaper
root@Ubuntu-1604-xenial-64-minimal /home/user # ipython
In [1]: import newspaper