Issue
I installed google-api-python-client on my Ubuntu 13.04 with
sudo easy_install --upgrade google-api-python-client
as it is said here.
After that I tried to translate something in python with it. I took the code from here.
>>> from apiclient.discovery import build
>>> service = build('translate', 'v2', developerKey='MyApiKey')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.1-py2.7.egg/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.1-py2.7.egg/apiclient/discovery.py", line 192, in build
resp, content = http.request(requested_url)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1570, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1317, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1252, in _conn_request
conn.connect()
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1021, in connect
self.disable_ssl_certificate_validation, self.ca_certs)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 80, in _ssl_wrap_socket
cert_reqs=cert_reqs, ca_certs=ca_certs)
File "/usr/lib/python2.7/ssl.py", line 440, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 198, in __init__
ciphers)
ssl.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
What is wrong?
Actually, I first wanted to do that in Spyder, but it failed to start:
ilya@ilya-laptop:~/Projects/online-translator$ spyder
Traceback (most recent call last):
File "/usr/bin/spyder", line 3, in <module>
start_app.main()
File "/usr/lib/python2.7/dist-packages/spyderlib/start_app.py", line 64, in main
from spyderlib import spyder
File "/usr/lib/python2.7/dist-packages/spyderlib/spyder.py", line 97, in <module>
from spyderlib.plugins.inspector import ObjectInspector
File "/usr/lib/python2.7/dist-packages/spyderlib/plugins/inspector.py", line 36, in <module>
from spyderlib.widgets.ipython import IPythonControlWidget
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/ipython.py", line 12, in <module>
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/rich_ipython_widget.py", line 20, in <module>
from ipython_widget import IPythonWidget
File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/ipython_widget.py", line 25, in <module>
from frontend_widget import FrontendWidget
File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/frontend_widget.py", line 10, in <module>
from pygments.lexers import PythonLexer
File "/usr/lib/python2.7/dist-packages/pygments/lexers/__init__.py", line 18, in <module>
from pygments.plugin import find_plugin_lexers
File "/usr/lib/python2.7/dist-packages/pygments/plugin.py", line 39, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2823, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 710, in subscribe
callback(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2823, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2255, in activate
self.insert_on(path)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2362, in insert_on
self.check_version_conflict()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2401, in check_version_conflict
for modname in self._get_metadata('top_level.txt'):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2249, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1219, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1211, in get_metadata
return self._get(self._fn(self.egg_info,name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1326, in _get
stream = open(path, 'rb')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.1-py2.7.egg/EGG-INFO/top_level.txt'
Traceback (most recent call last):
File "/usr/bin/spyder", line 3, in <module>
start_app.main()
File "/usr/lib/python2.7/dist-packages/spyderlib/start_app.py", line 64, in main
from spyderlib import spyder
File "/usr/lib/python2.7/dist-packages/spyderlib/spyder.py", line 97, in <module>
from spyderlib.plugins.inspector import ObjectInspector
File "/usr/lib/python2.7/dist-packages/spyderlib/plugins/inspector.py", line 36, in <module>
from spyderlib.widgets.ipython import IPythonControlWidget
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/ipython.py", line 12, in <module>
from IPython.frontend.qt.console.rich_ipython_widget import RichIPythonWidget
File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/rich_ipython_widget.py", line 20, in <module>
from ipython_widget import IPythonWidget
File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/ipython_widget.py", line 25, in <module>
from frontend_widget import FrontendWidget
File "/usr/lib/python2.7/dist-packages/IPython/frontend/qt/console/frontend_widget.py", line 10, in <module>
from pygments.lexers import PythonLexer
File "/usr/lib/python2.7/dist-packages/pygments/lexers/__init__.py", line 18, in <module>
from pygments.plugin import find_plugin_lexers
File "/usr/lib/python2.7/dist-packages/pygments/plugin.py", line 39, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2823, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 710, in subscribe
callback(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2823, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2255, in activate
self.insert_on(path)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2362, in insert_on
self.check_version_conflict()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2401, in check_version_conflict
for modname in self._get_metadata('top_level.txt'):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2249, in _get_metadata
for line in self.get_metadata_lines(name):
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1219, in get_metadata_lines
return yield_lines(self.get_metadata(name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1211, in get_metadata
return self._get(self._fn(self.egg_info,name))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1326, in _get
stream = open(path, 'rb')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.1-py2.7.egg/EGG-INFO/top_level.txt'
So somehow, google_api_python_client interferes with it's starting. WTF is wrong with google API bindings to python? Or with me?
Please, help.
Solution
From the traceback you received when trying to start Spyder, it looks like the Google API Python client has failed to install with the correct permissions. More precisely, Spyder is attempting to load components from IPython which make use of the Pygments syntax highlighter. Pygments is attempting to auto-discover packages using the pkg_resources
module, but it can't read the google_api_python_client
egg because of a permissions issue. I suspect that if you attempt to run Spyder as root it might launch okay.
Apparently, there are multiple potential sources of this problem. It can happen either because the Google package simply isn't built correctly, as described here, or it might be that you have another version of setuptools
lingering somewhere, as described here. You might try removing google_api_python_client
and re-installing via pip
. In any case, removing google_api_python_client
should allow Spyder to start normally again.
Answered By - Jed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.