jupyter_to_medium icon indicating copy to clipboard operation
jupyter_to_medium copied to clipboard

JSONDecodeError -

Open ravi-ramadoss opened this issue 1 year ago • 0 comments

Issue: Throws an error when I try to publish from notebook Expected: The notebook gets published Actual: Errors out Steps

  1. Created my integration token
  2. saved in vi ~/.jupyter_to_medium/integration_token
  3. I ran the code below
print('hi')
import jupyter_to_medium as jtm
jtm.publish('feature_engineering.ipynb',
            integration_token=None,
            pub_name=None,
            title=None,
            tags=None,
            publish_status='draft',
            notify_followers=False,
            license='all-rights-reserved',
            canonical_url=None,
            chrome_path=None,
            save_markdown=False,
            table_conversion='chrome',
            gistify=False,
            gist_threshold=5,
            public_gists=True
            )

got the below error

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
File ~/opt/anaconda3/envs/ai/lib/python3.10/site-packages/requests/models.py:971, in Response.json(self, **kwargs)
    970 try:
--> 971     return complexjson.loads(self.text, **kwargs)
    972 except JSONDecodeError as e:
    973     # Catch JSON-related errors and raise as requests.JSONDecodeError
    974     # This aliases json.JSONDecodeError and simplejson.JSONDecodeError

File ~/opt/anaconda3/envs/ai/lib/python3.10/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    343 if (cls is None and object_hook is None and
    344         parse_int is None and parse_float is None and
    345         parse_constant is None and object_pairs_hook is None and not kw):
--> 346     return _default_decoder.decode(s)
    347 if cls is None:

File ~/opt/anaconda3/envs/ai/lib/python3.10/json/decoder.py:337, in JSONDecoder.decode(self, s, _w)
    333 """Return the Python representation of ``s`` (a ``str`` instance
    334 containing a JSON document).
    335 
    336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338 end = _w(s, end).end()

File ~/opt/anaconda3/envs/ai/lib/python3.10/json/decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
    354 except StopIteration as err:
--> 355     raise JSONDecodeError("Expecting value", s, err.value) from None
    356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

JSONDecodeError                           Traceback (most recent call last)
Cell In[2], line 2
      1 import jupyter_to_medium as jtm
----> 2 jtm.publish('feature_engineering.ipynb',
      3             integration_token=None,
      4             pub_name=None,
      5             title=None,
      6             tags=None,
      7             publish_status='draft',
      8             notify_followers=False,
      9             license='all-rights-reserved',
     10             canonical_url=None,
     11             chrome_path=None,
     12             save_markdown=False,
     13             table_conversion='chrome',
     14             gistify=False,
     15             gist_threshold=5,
     16             public_gists=True
     17             )

File ~/opt/anaconda3/envs/ai/lib/python3.10/site-packages/jupyter_to_medium/_publish_to_medium.py:449, in publish(filename, integration_token, pub_name, title, tags, publish_status, notify_followers, license, canonical_url, chrome_path, save_markdown, table_conversion, gistify, gist_threshold, public_gists)
    348 """
    349 Publish a Jupyter Notebook directly to Medium as a blog post.
    350 
   (...)
    430     or private (only accessible through link).
    431 """
    432 p = Publish(
    433     filename,
    434     integration_token,
   (...)
    447     public_gists,
    448 )
--> 449 p.main()
    450 return p.result

File ~/opt/anaconda3/envs/ai/lib/python3.10/site-packages/jupyter_to_medium/_publish_to_medium.py:306, in Publish.main(self)
    305 def main(self):
--> 306     self.author_id = self.get_author_id()
    307     self.pub_id = self.get_pub_id()
    308     # this is the main function for converting images etc

File ~/opt/anaconda3/envs/ai/lib/python3.10/site-packages/jupyter_to_medium/_publish_to_medium.py:134, in Publish.get_author_id(self)
    132 r = requests.get(self.AUTHOR_URL, headers=self.headers)
    133 try:
--> 134     return r.json()["data"]["id"]
    135 except KeyError:
    136     raise ValueError("Problem authenticating author: \n" + r.text)

File ~/opt/anaconda3/envs/ai/lib/python3.10/site-packages/requests/models.py:975, in Response.json(self, **kwargs)
    971     return complexjson.loads(self.text, **kwargs)
    972 except JSONDecodeError as e:
    973     # Catch JSON-related errors and raise as requests.JSONDecodeError
    974     # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 975     raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

ravi-ramadoss avatar Mar 31 '24 01:03 ravi-ramadoss