Windows local appengine usage: oauth2client ImportError - python-2.7

I m working with App Engine Standard, developing a Python backend service and, at some point, I told myself:
"Hey why don't you try out and run the server locally while using the remote Datastore"
I can run this code locally but I couldn't figure out why the remote_api_stub throws the error :
" File "C:\Program Files (x86)\Google\Cloud
SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py",
line 1003, in ConfigureRemoteApiForOAuth 'oauth2client module: %s' %
e)
ImportError: Use of OAuth credentials requires the oauth2client
module: No module named oauth2client"
Even though, according to pip, I got the oauth2client installed already (I see that when I run pip install --upgrade oauth2client
Thank you in advance for your help
EDIT:
My issue is not a duplicate of ImportError: No module named oauth2client. I yet did install google api client in the lib folder and made sure the "appengine_config.py" file was in its place with the necessary lines.
It still didn't resolve my issue, so I'm going to give more details about it !
Here is my main.py (taking care of the default service of GAE) or at least a degreased version of what it is:
import os
import datetime
import dev_appserver
from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.api import apiproxy_stub_map
dev_appserver.fix_sys_path()
local_urlfetch_stub = apiproxy_stub_map.apiproxy.GetStub('urlfetch')
def configure_remote_api_dev_safe (host):
if not os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
logging.info("running on local server")
remote_api_stub.ConfigureRemoteApiForOAuth(host, '/_ah/remote_api')
apiproxy_stub_map.apiproxy.ReplaceStub('urlfetch', local_urlfetch_stub)
else:
logging.info("running on remote server")
def configure_remote_api_dev_unsafe (host):
if not os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/'):
remote_api_stub.ConfigureRemoteApiForOAuth(host, '/_ah/remote_api')
else:
logging.info("running on remote server")
class Main(webapp2.RequestHandler):
def post(self):
configure_remote_api_dev_safe ('{}.appspot.com'.format(app))
test = Test(createdAt=datetime.datetime.utcnow())
test.put()
self.response.write("done")
app = ndb.toplevel(webapp2.WSGIApplication({('/', Main)}, debug=True))
And I get this error when I request the default service:
PATH_TO_PROJECT_FOLDER>dev_appserver.py PATH_TO_PROJECT_FOLDER
INFO 2018-07-20 10:45:17,740 devappserver2.py:178] Skipping SDK update check.
INFO 2018-07-20 10:45:18,117 api_server.py:274] Starting API server at: http://localhost:53725
INFO 2018-07-20 10:45:18,151 dispatcher.py:270] Starting module "default" running at: http://localhost:8080
INFO 2018-07-20 10:45:18,153 admin_server.py:152] Starting admin server at: http://localhost:8000
INFO 2018-07-20 10:46:57,006 instance.py:294] Instance PID: 5940
WARNING 2018-07-20 08:46:57,565 sandbox.py:1086] The module _winreg is whitelisted for local dev only. If your application relies on _winreg, it is likely that it will not function properly in production.
INFO 2018-07-20 08:46:57,757 main.py:35] running on local server
ERROR 2018-07-20 08:46:57,760 webapp2.py:1528] Use of OAuth credentials requires the oauth2client module: No module named oauth2client
Traceback (most recent call last):
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1077, in __call__
return handler.dispatch()
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "PATH_TO_PROJECT_FOLDER\main.py", line 125, in post
configure_remote_api_dev_safe ('{}.appspot.com'.format(app))
File "PATH_TO_PROJECT_FOLDER\main.py", line 38, in configure_remote_api_dev_safe'/_ah/remote_api')
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 1003, in ConfigureRemoteApiForOAuth 'oauth2client module: %s' % e)
ImportError: Use of OAuth credentials requires the oauth2client module: No module named oauth2client
ERROR 2018-07-20 08:46:57,765 wsgi.py:279]
Traceback (most recent call last):
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 267, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\ndb\tasklets.py", line 1108, in add_context_wrapper
return synctaskletfunc(*args, **kwds)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\ndb\tasklets.py", line 1087, in synctasklet_wrapper
return taskletfunc(*args, **kwds).get_result()
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\ndb\tasklets.py", line 1057, in tasklet_wrapper
result = func(*args, **kwds)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 1077, in __call__
return handler.dispatch()
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\lib\webapp2-2.3\webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "PATH_TO_PROJECT_FOLDER\main.py", line 125, in post
configure_remote_api_dev_safe ('{}.appspot.com'.format(app))
File "PATH_TO_PROJECT_FOLDER\main.py", line 38, in configure_remote_api_dev_safe '/_ah/remote_api')
File "SDK_PATH\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 1003, in ConfigureRemoteApiForOAuth 'oauth2client module: %s' % e)
ImportError: Use of OAuth credentials requires the oauth2client module: No module named oauth2client
INFO 2018-07-20 10:46:57,782 module.py:880] default: "POST / HTTP/1.1" 500 -
I hope that this is more explanatory. Thank you again in advance for your help!
Solution : (Thanks to #Dan Cornilescu)
=> Simply never forget the "import dev_appserver" and the call to "dev_appserver.fix_sys_path()"
I had them lost at the first place because of code versioning (a bad cherry pick) while I thought I had everything right.
Yet I'm not done and I'm facing a new issue that I m going to type down in a new question because its unrelated to the cause of this one(I hope nothing else got lost at some point). [ if you are curious about the the new issue its right here]

Converting the relevant comment to an answer.
The code snippet you shown seems to be missing this apparently needed setup section from the Using the Remote API in a local client example:
try:
import dev_appserver
dev_appserver.fix_sys_path()
except ImportError:
print('Please make sure the App Engine SDK is in your PYTHONPATH.')
raise

Related

Flask-SocketIO WebSocket transport is not available

I've got a Flask server with Flask-SocketIO to do instant reloads on some pages. Now I'm getting this message in the console:
The WebSocket transport is not available, you must install a WebSocket server that is compatible with your async mode to enable it. See the documentation for details.
Like discribed here https://github.com/miguelgrinberg/Flask-SocketIO/issues/647 I tried to install gevent or eventlet, but neither one changed anything.
The code on the Client is like this:
import { io } from "https://cdn.socket.io/4.4.1/socket.io.esm.min.js";
var socket = io();
socket.emit(event,data,(response) => {response_func(response);})
On the Server:
#socketio.on(event)
def functionOnEvent(data):
functions(data)
return data
Both code samples are of course simplified, but there is no async call of any sort.
Update:
After installing eventlet again and manually setting the async_mode the message disappeared. But now I get the following error from eventlet:
ERROR:Error on request:
Traceback (most recent call last):
File "C:\...\venv\lib\site-packages\werkzeug\serving.py", line 319, in run_wsgi
execute(self.server.app)
File "C:\...\venv\lib\site-packages\werkzeug\serving.py", line 306, in execute
application_iter = app(environ, start_response)
File "C:\...\venv\lib\site-packages\flask\app.py", line 2095, in __call__
return self.wsgi_app(environ, start_response)
File "C:\...\venv\lib\site-packages\flask_socketio\__init__.py", line 43, in __call__
return super(_SocketIOMiddleware, self).__call__(environ,
File "C:\...\venv\lib\site-packages\engineio\middleware.py", line 63, in __call__
return self.engineio_app.handle_request(environ, start_response)
File "C:\...\venv\lib\site-packages\socketio\server.py", line 597, in handle_request
return self.eio.handle_request(environ, start_response)
File "C:\...\venv\lib\site-packages\engineio\server.py", line 411, in handle_request
packets = socket.handle_get_request(
File "C:\...\venv\lib\site-packages\engineio\socket.py", line 103, in handle_get_request
return getattr(self, '_upgrade_' + transport)(environ,
File "C:\...\venv\lib\site-packages\engineio\socket.py", line 158, in _upgrade_websocket
return ws(environ, start_response)
File "C:\...\venv\lib\site-packages\engineio\async_drivers\eventlet.py", line 16, in __call__
raise RuntimeError('You need to use the eventlet server. '
RuntimeError: You need to use the eventlet server. See the Deployment section of the documentation for more information.
As far as I unterstand and show in this example https://github.com/miguelgrinberg/Flask-SocketIO-Chat I thought when running the app like socketio.run(app), it should automatically run an eventlet server?

Request Google cloud speech-to-text API gives 503 error?

I ran the following python sample code on this page (you need a private key to run this): https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries
# Imports the Google Cloud client library
from google.cloud import speech
import os
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'key.json'
# Instantiates a client
client = speech.SpeechClient()
# The name of the audio file to transcribe
gcs_uri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw"
audio = speech.RecognitionAudio(uri=gcs_uri)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
)
# Detects speech in the audio file
response = client.recognize(config=config, audio=audio)
for result in response.results:
print("Transcript: {}".format(result.alternatives[0].transcript))
This results in the following error:
Traceback (most recent call last):
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\api_core\grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\grpc\_channel.py", line 826, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\grpc\_channel.py", line 729, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"#1614347442.192000000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":4090,"referenced_errors":[{"created":"#1614347442.192000000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":394,"grpc_status":14}]}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\api_core\retry.py", line 184, in retry_target
return target()
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.ServiceUnavailable: 503 failed to connect to all addresses
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:/Users/98274/Desktop/carla_ppo/test_connection.py", line 22, in <module>
response = client.recognize(config=config, audio=audio)
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\cloud\speech_v1\services\speech\client.py", line 334, in recognize
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\api_core\gapic_v1\method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\api_core\retry.py", line 286, in retry_wrapped_func
on_error=on_error,
File "C:\Users\98274\anaconda3\envs\carla\lib\site-packages\google\api_core\retry.py", line 206, in retry_target
last_exc,
File "<string>", line 3, in raise_from
google.api_core.exceptions.RetryError: Deadline of 120.0s exceeded while calling functools.partial(<function _wrap_unary_errors.<locals>.error_remapped_callable at 0x0000026B56606A68>, config {
encoding: LINEAR16
sample_rate_hertz: 16000
language_code: "en-US"
}
audio {
uri: "gs://cloud-samples-data/speech/brooklyn_bridge.raw"
}
, metadata=[('x-goog-api-client', 'gl-python/3.7.9 grpc/1.31.0 gax/1.23.0 gapic/2.0.1')]), last exception: 503 failed to connect to all addresses
What's the problem? Does it related to internet issue because I am in China? How can I solve it?
I am posting the answer as CommunityWiki to further contribuite to the community.
As discussed in the comment section, the code provided in the documentation is running smoothly. However, you have to make sure that you set your credentials using GOOGLE_APPLICATION_CREDENTIALS so your request is authenticated. Also,the client libraries have to be properly installed.
In #antaressgzz case's the request to the API was being blocked by a firewall rule. Thus, it is a good practice to check these rules, changing them if applicable.

My project is on Google App Engine(webapp2). I am not able to import firebase-admin

I am developing my web app using webapp2. I have tried to setup firebase-admin but I am not able to import it. The firebase-admin files are in the lib folder.I have also added the lib folder by vendor.add.
If I import the firebase-admin using lib.firebase-admin it works. But there are alot of imports in the init.py folder of the firebase-admin. Thus even those imports are not working.
from firebase_admin import auth
The above line of code
'from firebase_admin import auth' does not work. But 'lib.firebase_admin import auth' works. This is a workaround which isnt feasible.
The stack trace is below:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Users\Farrukh Bin Rashid\Documents\Internship\Blog-GoogleSearchAPI - Firebase Admin\Blog\controllers\Handler.py", line 10, in dispatch
webapp2.RequestHandler.dispatch(self)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Users\Farrukh Bin Rashid\Documents\Internship\Blog-GoogleSearchAPI - Firebase Admin\Blog\controllers\Home.py", line 22, in get
default_app = firebase_admin.initialize_app()
File "C:\Users\Farrukh Bin Rashid\Documents\Internship\Blog-GoogleSearchAPI - Firebase Admin\Blog\lib\firebase_admin\__init__.py", line 62, in initialize_app
credential = credentials.ApplicationDefault()
File "C:\Users\Farrukh Bin Rashid\Documents\Internship\Blog-GoogleSearchAPI - Firebase Admin\Blog\lib\firebase_admin\credentials.py", line 128, in __init__
self._g_credential, self._project_id = lib.google.auth.default(scopes=_scopes)
File "C:\Users\Farrukh Bin Rashid\Documents\Internship\Blog-GoogleSearchAPI - Firebase Admin\Blog\lib\google\auth\_default.py", line 281, in default
credentials, project_id = checker()
File "C:\Users\Farrukh Bin Rashid\Documents\Internship\Blog-GoogleSearchAPI - Firebase Admin\Blog\lib\google\auth\_default.py", line 111, in _get_gcloud_sdk_credentials
from google.auth import _cloud_sdk
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime\sandbox.py", line 1174, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.auth```
If you are using Python 2.7 on App Engine, you will need to follow these steps in order to use this library. If you are using Python 3.7, you can just use your requirements.txt and won’t need to use vendor.add().

Using tools.run_flow() raises SSLHandshake "certificate verify" error in Google Sheets API tutorial

I'm am pretty much following the Google Sheets getting started (in Python) to a tee. I've gotten the program to work on my Mac laptop, but it is failing as I am trying to run it on Windows. So far, I've checked that we do not have the firewall enabled on the machine.
Below is the error that appears after clicking through the authentication prompts that pop up in the browser.
Traceback (most recent call last):
File "Authenticate.py", line 47, in <module>
main()
File "Authenticate.py", line 43, in main
tools.run_flow(flow, store)
File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\tools.py", line 243, in run_flow
credential = flow.step2_exchange(code, http=http)
File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\client.py", line 2054, in step2_exchange
http, self.token_uri, method='POST', body=body, headers=headers)
File "C:\johnsnow\packages\test\lib\site-packages\oauth2client\transport.py", line 282, in request
connection_type=connection_type)
File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1570, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1317, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1252, in _conn_request
conn.connect()
File "C:\johnsnow\packages\test\lib\site-packages\httplib2\__init__.py", line 1044, in connect
raise SSLHandshakeError(e)
httplib2.SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)
I'm not exactly sure how it happened as I was working in a virtualenv, but there was a dependency issue in the version of httplib2 and oauth2. After an uninstall and then reinstall, there was an error that the two libraries were incompatible.
Doing pip freeze showed I had httplib2==0.8 but oauth2client required httplib2=>0.9.
This was resolved by doing pip install --upgrade httplib2.

Runtime error when trying to use pip

I have managed to royally screw myself over by doing something which seemed innocuous.
i was getting the following error from my python script (brand['feed'] = the URL i'm making the request to):
**C:\Python27\lib\site-packages\requests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Traceback (most recent call last):
File "D:\Phocas\Phocas-Automation\analytics\download_feed_cats.py", line 18, in <module>
data = requests.get(brand['feed'])
File "C:\Python27\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 594, in send
history = [resp for resp in gen] if allow_redirects else []
File "C:\Python27\lib\site-packages\requests\sessions.py", line 196, in resolve_redirects
**adapter_kwargs
File "C:\Python27\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 431, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed**
So i asked the internet and the internet said do this:
pip install --upgrade ndg-httpsclient
So i did that and now i keep getting a RuntimeError when i run the same script, what's crazy is even if i just try and run pip in the shell, i get the same error!!
Phocas_Tommy#p3303386 MINGW64 /c/Python27
$ pip
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python27\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Python27\lib\site-packages\pip\download.py", line 22, in <module>
from pip._vendor import requests, six
File "C:\Python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\contrib\pyopenssl.py", line 43, in <module>
import OpenSSL.SSL
File "C:\Python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "C:\Python27\lib\site-packages\OpenSSL\rand.py", line 12, in <module>
from OpenSSL._util import (
File "C:\Python27\lib\site-packages\OpenSSL\_util.py", line 9, in <module>
binding = Binding()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 114, in __init__
self._ensure_ffi_initialized()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 126, in _ensure_ffi_initialized
cls._modules,
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 31, in load_library_for_binding
lib = ffi.verifier.load_library()
File "C:\Python27\lib\site-packages\cffi\verifier.py", line 96, in load_library
self._compile_module()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 127, in _compile_module
"Attempted implicit compile of a cffi module. All cffi modules should "
RuntimeError: Attempted implicit compile of a cffi module. All cffi modules should be pre-compiled at installation time.
I have searched this error and can't seem to find anything which helps. I'm using python 2.7.6 on Windows Server 2008 R2 Standard 64-bit
Re-installing Python fixed this problem