SSL backend error when using OpenSSL

for most people After reading their INSTALLATION file, I was able to solve my problem by setting an environment variable and did a reinstall # remove existing `pycurl` installation pip uninstall pycurl # export variable with your link-time ssl backend (which is openssl above) export PYCURL_SSL_LIBRARY=openssl # then, re-install `pycurl` with **no cache** pip install … Read more

Execute curl command within a Python script

Don’t! I know, that’s the “answer” nobody wants. But if something’s worth doing, it’s worth doing right, right? This seeming like a good idea probably stems from a fairly wide misconception that shell commands such as curl are anything other than programs themselves. So what you’re asking is “how do I run this other program, … Read more

How do I get the IP address from a http request using the requests library?

It turns out that it’s rather involved. Here’s a monkey-patch while using requests version 1.2.3: Wrapping the _make_request method on HTTPConnectionPool to store the response from socket.getpeername() on the HTTPResponse instance. For me on python 2.7.3, this instance was available on response.raw._original_response. from requests.packages.urllib3.connectionpool import HTTPConnectionPool def _make_request(self,conn,method,url,**kwargs): response = self._old_make_request(conn,method,url,**kwargs) sock = getattr(conn,’sock’,False) if … Read more

Why can’t Python find shared objects that are in directories in sys.path?

sys.path is only searched for Python modules. For dynamic linked libraries, the paths searched must be in LD_LIBRARY_PATH. Check if your LD_LIBRARY_PATH includes /usr/local/lib, and if it doesn’t, add it and try again. Some more information (source): In Linux, the environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for … Read more