chembl / chembl_webresource_client

Official Python client for accessing ChEMBL API
https://www.ebi.ac.uk/chembl/api/data/docs
Other
371 stars 95 forks source link

No connection without error message. #5

Closed sorenwacker closed 8 years ago

sorenwacker commented 9 years ago

Hi,

thank you for this client its really helpful software! The following comes up, when I initiate the client from an activated anaconda-environment. The connection works, when the environment is deactivated. It seems there are certain dependencies not fullfilled, however the error message does not say what exactly goes wrong. Are you aware of specific python packages (environment conditions in general) to run the chembl client??

here is what happens ----->

import chembl_webresource_client as cwc assays = cwc.AssayResource() assays.status()


TypeError Traceback (most recent call last)

in () 1 import chembl_webresource_client as cwc 2 assays = cwc.AssayResource() ----> 3 targets.status() /home/swacker/Programme/anaconda/lib/python2.7/site-packages/chembl_webresource_client/web_resource.pyc in status(self) 95 def status(self): 96 service = self.get_service() ---> 97 if not 'status' in service: 98 return False 99 return service['status'] == 'UP' TypeError: argument of type 'NoneType' is not iterable
mnowotka commented 9 years ago

Hi @teramind, thank you for using our client. Can you check this ticket: https://github.com/chembl/chembl_webresource_client/issues/1, I think it describes your problem. This boils down to incompatibility of python 2.7.9, which breaks urllib3 (https://github.com/shazow/urllib3/issues/482) and gevent (https://github.com/gevent/gevent/issues/477).

There are basically two solutions:

  1. Change your python version to 2.7.6 or lower for example by doing:

    conda create -q -n py276 python=2.7.6 

    You can take a look at how we configure our environment to perform travis tests (https://github.com/chembl/chembl_webresource_client/blob/master/.travis.yml).

  2. Use new part of the client called new_client. It implements django-like interface and is generally more flexible than older client you are currently using. It doesn't use gevent anymore so there shouldn't be any compatibility issues. One example of using it is here: https://gist.github.com/mnowotka/c0fff4f8560c17e0b473, lots of other examples are covered in tests (https://github.com/chembl/chembl_webresource_client/blob/master/chembl_webresource_client/tests.py). There will be a blog post next week, which will hopefully cover all the important features of the new client. If you have any specific questions, you can ask them here or contact us via email: chembl-help@ebi.ac.uk.
sorenwacker commented 9 years ago

Thanks!

Going back to python 2.7.6 resolved the connection issue. I can also import the new client. However, now other things don't work.

With python 2.7.9, this:

from chembl_webresource_client.new_client import new_client

gives me ... /home/swacker/Programme/anaconda/envs/env1/lib/python2.7/ssl.pyc in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname) 348 suppress_ragged_eofs=suppress_ragged_eofs, 349 server_hostname=server_hostname, --> 350 _context=self) 351 352 def set_npn_protocols(self, npn_protocols):

TypeError: init() got an unexpected keyword argument 'server_hostname'

mnowotka commented 9 years ago

OK, in that case, I think that currently only the first solution (changing python version) is valid. Can you check, which python version are you currently using?

sorenwacker commented 9 years ago

OK, the reason why my old scripts did not work was because some names changed. E.g. chemblId to chemblid. I appreciate that. I found one inconsistency with the old client:

compounds = cwc.CompoundResource() compounds.get()

still returns chemblId instead of chemblid.