Certificate folder not found

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tradernz
    Junior Member
    • Feb 2016
    • 19

    #1

    Certificate folder not found

    Hey all,

    I've setup Python and installed the 1.8.3 Betfairlightweight

    I have then tried running the
    Code:
     
     # Import libraries import betfairlightweight from betfairlightweight import filters import pandas as pd import numpy as np import os import datetime import json  # Change this certs path to wherever you're storing your certificates certs_path = r'C:\Users\wardj\Desktop\certs'  # Change these login details to your own my_username = "your_username" my_password = "your_password" my_app_key = "your_app_key"  trading = betfairlightweight.APIClient(username=my_username,                                        password=my_password,                                        app_key=my_app_key,                                        certs=certs_path)  trading.login()
    However it is coming up with this output

    Code:
     
     CertsError                                Traceback (most recent call last) ~\Anaconda3\lib\site-packages\betfairlightweight\endpoints\login.py in request(self, method, params, session)      37         try: ---> 38             response = session.post(self.url, data=self.data, headers=self.client.login_headers, cert=self.client.cert)      39         except ConnectionError:  ~\Anaconda3\lib\site-packages\betfairlightweight\baseclient.py in cert(self)     154         if cert is None or key is None: --> 155             raise CertsError(certs)     156         return [cert, key]  CertsError: Certificate folder not found in C:/certs  During handling of the above exception, another exception occurred:  APIError                                  Traceback (most recent call last) <ipython-input-19-b1974ee2ecba> in <module>      21                                        certs=certs_path)      22  ---> 23 trading.login()  ~\Anaconda3\lib\site-packages\betfairlightweight\endpoints\login.py in __call__(self, session, lightweight)      28         :rtype: LoginResource      29         """ ---> 30         (response, elapsed_time) = self.request(self.url, session=session)      31         self.client.set_session_token(response.get('sessionToken'))      32         return self.process_response(response, LoginResource, elapsed_time, lightweight)  ~\Anaconda3\lib\site-packages\betfairlightweight\endpoints\login.py in request(self, method, params, session)      40             raise APIError(None, exception='ConnectionError')      41         except Exception as e: ---> 42             raise APIError(None, exception=e)      43         elapsed_time = (datetime.datetime.utcnow() - date_time_sent).total_seconds()      44   APIError: None  Params: None  Exception: Certificate folder not found in C:/certs
    I have tried things like changing the backslash to a forward slash but no luck. I was able to connect using the some sample code from the betfairlightweight github via the interactive login option but im guessing thats not really what I want to be using long term.
    HTML Code:
     The library can then be used as follows:    >>> import betfairlightweight  >>> trading = betfairlightweight.APIClient('username', 'password', app_key='app_key', certs='/certs')  >>> trading.login() 
    or the following for interactive login (no certs)  >>> trading.login_interactive()
    Any ideas on what im doing wrong on this one?

    Cheers
    Rob
  • LiamP
    Junior Member
    • Oct 2015
    • 284

    #2
    The error is saying you don’t have a C:/certs folder, do you?

    Comment

    • tradernz
      Junior Member
      • Feb 2016
      • 19

      #3
      Hey ya.... Yeh sure do... created it and added in the 2 files as required in the online documentation..

      Comment

      • tradernz
        Junior Member
        • Feb 2016
        • 19

        #4
        Is there any other requirements for the folder location etc ... ?

        Comment

        • LiamP
          Junior Member
          • Oct 2015
          • 284

          #5
          I assume you are using windows, try putting an ‘r’ in front of the string

          Code:
          r’/“certs”
          ok the forum is stripping my quotes but imagine there are quotes surrounding and a forward bracket in front of certs
          Last edited by LiamP; 23-03-2019, 11:47 AM. Reason: fucking stupid char stripping

          Comment

          • tradernz
            Junior Member
            • Feb 2016
            • 19

            #6
            Hey mate, yeh using windows....

            certs_path = r'/"certs"

            is getting me

            File "<ipython-input-23-e458ea84454c>", line 11 certs_path = r'/"certs" ^ SyntaxError: EOL while scanning string literal

            Comment

            • tradernz
              Junior Member
              • Feb 2016
              • 19

              #7
              Code:
              # Change this certs path to wherever you're storing your certificates
              certs_path = r'/certs'
              Cheers to LiamP for helping sort this out.... hoping this displays correctly.

              Cheers
              Rob

              Comment

              • kerchowey
                Junior Member
                • May 2019
                • 8

                #8
                Hi,

                I am having the same problem as tradernz i.e. installed betfair lightweight, have created the certs/linked them to my account and am getting the following error:

                --------------------------------------------------------------------------- APIError Traceback (most recent call last) <ipython-input-13-76672fb37c0d> in <module>() ----> 1 trading.login() C:\Users\Joey\Anaconda2\lib\site-packages\betfairlightweight\endpoints\login.pyc in __call__(self, session, lightweight) 28 :rtype: LoginResource 29 """ ---> 30 (response, elapsed_time) = self.request(self.url, session=session) 31 self.client.set_session_token(response.get('sessio nToken')) 32 return self.process_response(response, LoginResource, elapsed_time, lightweight) C:\Users\Joey\Anaconda2\lib\site-packages\betfairlightweight\endpoints\login.pyc in request(self, method, params, session) 40 raise APIError(None, exception='ConnectionError') 41 except Exception as e: ---> 42 raise APIError(None, exception=e) 43 elapsed_time = (datetime.datetime.utcnow() - date_time_sent).total_seconds() 44 APIError: None Params: None Exception: Certificate folder not found in C:\certs I believe I am following the same advice I am having the same problem as tradernz i.e. installed betfair lightweight, have created the certs/linked them to my account and am getting the following error:

                I have the certs_path variable set to
                certs_path = r'C:\certs'

                and executing the following code:
                trading = betfairlightweight.APIClient(username=my_username, password=my_password,app_key=my_app_key,certs=cert s_path)
                trading.login()

                which generates the error above.

                I've also tried changing the slashes etc. but no luck. Any ideas what I'm doing wrong? Note I have no problems connecting with login_interactive()

                Cheers

                Comment

                • LiamP
                  Junior Member
                  • Oct 2015
                  • 284

                  #9
                  What version are you running?

                  Comment

                  • kerchowey
                    Junior Member
                    • May 2019
                    • 8

                    #10
                    Hi LiamP - I am running version 1.9.0 of betfairlightweight.

                    Comment

                    • LiamP
                      Junior Member
                      • Oct 2015
                      • 284

                      #11
                      Originally posted by kerchowey View Post
                      Hi LiamP - I am running version 1.9.0 of betfairlightweight.
                      Hmm, are you a UK user?

                      Comment

                      • kerchowey
                        Junior Member
                        • May 2019
                        • 8

                        #12
                        No I am an Australian user.

                        Comment

                        • LiamP
                          Junior Member
                          • Oct 2015
                          • 284

                          #13
                          Originally posted by kerchowey View Post
                          No I am an Australian user.
                          Are you setting the locale? Although this shouldn’t make a difference on cert login as the docs say Australia uses the same endpoint.

                          Comment

                          • kerchowey
                            Junior Member
                            • May 2019
                            • 8

                            #14
                            No I am not setting the locale. Full code below (note I am filling in the username/pw etc with my details):

                            import betfairlightweight
                            from betfairlightweight import filters
                            import pandas as pd
                            import numpy as np
                            import os
                            import datetime
                            import json
                            import math
                            pd.options.mode.chained_assignment = None # default='warn'

                            certs_path = r'C:/certs'
                            my_username = ...
                            my_password = ...
                            my_app_key = ...

                            trading = betfairlightweight.APIClient(username=my_username, password=my_password,app_key=my_app_key,certs=cert s_path)
                            trading.login()

                            Comment

                            • LiamP
                              Junior Member
                              • Oct 2015
                              • 284

                              #15
                              Try setting it

                              Comment

                              Working...
                              X