![]() To see what path the module is connected to. apt-get remove python-openbabel import inspect I had to uninstall a few things to be certain, e.g. To see what version of openbabel your python uses – in my case it came back with 2.3.2, even though I had downloaded the 4.2.1 source and I thought I installed it. Here are a few commands that helped me figure it out: import openbabel Turns out, I had it but it wasn’t installed properly and there was a conflict with an older version. But I thought I had the latest (4.2.1) already. ![]() It seems that an older version of OpenBabel had a bug which vaguely was explained in several links (Matt Swain seems to have looked into this in detail some time the solution was obvious – install a newer version of openbabel. You will see a list full of garbage values as the first 3-4 items. Then, it all worked fine, but when I tried with my local installation of python 2.7 the strangest of all errors popped up: ValueError("8?עX? is not a recognised Open Babel descriptor type")Īfter a serious investigation the culprit was the calcdesc() or specifically the descs global variable in pybel. In a previous post I wrote about the pybel and openbabel code, which I tried using the MGLTools python interpreter (pythonsh). R = requests.post(gUSEurl, files=post_values, verify=False) # the post parameters: m='detailsinfo', pass='.', ID='.' I read this StackOverflow answer to encode strings as POST parameters in Request. Potential solution – use the attribute “files”! But, no luck… By default the Requests module will encode the name of the POST parameter as “name” but also a “filename”, even though you don’t specify a file name.įinally, what you should do is use this elaborate dictionary with POST parameter names as keys and as values: tuples which contain None as the first element, and the value of the string as second. ![]() I realised this after painstakingly inspecting the body of the request and comparing it with the request sent using P圜url. The problem here was that Requests silently won’t encode your POST parameters if they are strings and if you use the attribute “data”. # print the error code and message and raise the error again R = requests.post(gUSEurl, files=post_files, data=post_values, verify=False)Įxcept, e: # the post parameters: m='submit', pass='.', gusewf='.' (file), certs='.'(file) This is quite simple, you need to know that all errors in Requests inherit from “” if you want to catch any exception and this StackOverflow answer to handle Request errors properly.As I’ve shown here, it works if you use a list of tuples for both, where the first item in the tuple is the POST parameter name, and the second the value – in the case of the file, this needs to be opened, preferably in binary mode. You need the attributes “files” for the files, and “data” for the string values. I used help from this StackOverflow answer to submit both string values as post parameters and files. ![]() But, little did I know that you need to know a few tricks and lose a little hair before it will all work…įirst up, submitting a request to the gUSE RemoteAPI. I had an issue with installing Pycurl on a Mac, so I thought I would use the Requests module which seems much more elegant for simple http requests.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |