coddingtonbear / python-myfitnesspal

Access your meal tracking data stored in MyFitnessPal programatically
MIT License
794 stars 136 forks source link

FileNotFoundError when using myfitnesspal.Client() #78

Closed mcarlock1 closed 5 years ago

mcarlock1 commented 5 years ago
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/util/ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir)

FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    422         if isinstance(timeout, tuple):
--> 423             try:
    424                 connect, read = timeout

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, **response_kw)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connectionpool.py in _validate_conn(self, conn)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/connection.py in connect(self)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/packages/urllib3/util/ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir)

SSLError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

SSLError                                  Traceback (most recent call last)
<ipython-input-85-2f7865374943> in <module>
      2 
      3 
----> 4 myfitnesspal.Client(username = '')
      5 
      6 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in __init__(self, username, password, login, unit_aware)
     56         self.session = requests.Session()
     57         if login:
---> 58             self._login()
     59 
     60     @property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _login(self)
     84     def _login(self):
     85         login_url = parse.urljoin(self.BASE_URL_SECURE, self.LOGIN_PATH)
---> 86         document = self._get_document_for_url(login_url)
     87         authenticity_token = document.xpath(
     88             "(//input[@name='authenticity_token']/@value)[1]"

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_document_for_url(self, url)
    210 
    211     def _get_document_for_url(self, url):
--> 212         content = self._get_content_for_url(url)
    213 
    214         return lxml.html.document_fromstring(content)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_content_for_url(self, *args, **kwargs)
    206     def _get_content_for_url(self, *args, **kwargs):
    207         return (
--> 208             self._get_request_for_url(*args, **kwargs).content.decode('utf8')
    209         )
    210 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/myfitnesspal/client.py in _get_request_for_url(self, url, send_token, headers, **kwargs)
    201             url,
    202             headers=headers,
--> 203             **kwargs
    204         )
    205 

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py in get(self, url, **kwargs)
    486             for multipart encoding upload.
    487         :param auth: (optional) Auth tuple or callable to enable
--> 488             Basic/Digest/Custom HTTP Auth.
    489         :param timeout: (optional) How long to wait for the server to send
    490             data before giving up, as a float, or a :ref:`(connect timeout,

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    473         :param method: method for the new :class:`Request` object.
    474         :param url: URL for the new :class:`Request` object.
--> 475         :param params: (optional) Dictionary or bytes to be sent in the query
    476             string for the :class:`Request`.
    477         :param data: (optional) Dictionary, list of tuples, bytes, or file-like

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/sessions.py in send(self, request, **kwargs)
    594 
    595     def patch(self, url, data=None, **kwargs):
--> 596         r"""Sends a PATCH request. Returns :class:`Response` object.
    597 
    598         :param url: URL for the new :class:`Request` object.

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    495                     raise
    496 
--> 497         except (ProtocolError, socket.error) as err:
    498             raise ConnectionError(err, request=request)
    499 

SSLError: [Errno 2] No such file or directory
coddingtonbear commented 5 years ago

This could be any number of things; and fortunately for me, all are rooted deeper than this library itself. Looking at your traceback, though, it doesn't make any sense-- in many stack frames it has indicated lines in docstrings as the active line in that frame; I can't think of a reason for that to occur other than your running code differing from the code on-disk. If I were you, I'd close ipython and re-open it; that might clear something up.

mcarlock1 commented 5 years ago

doing a full restart fixed the issue when i ran in python idle instead of jupyter, thank you

coddingtonbear commented 5 years ago

Good to hear!