question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

TypeError: the JSON object must be str, not 'bytes'

See original GitHub issue

I successfully installed and use jupyterlab-toc:

jupyter labextension list
JupyterLab v0.32.1
Known labextensions:
   app dir: /data/srlab/slowikow/src/miniconda2/envs/py3/share/jupyter/lab
jupyterlab-toc
        jupyterlab-toc v0.2.1  enabled  OK

Today, I decided to try to upgrade to v0.3.1, but I get an error:

jupyter labextension install @jupyterlab/toc
> /data/srlab/slowikow/src/miniconda2/envs/py3/bin/npm pack @jupyterlab/toc
jupyterlab-toc-0.3.1.tgz

Errored, use --debug for full output:
TypeError: the JSON object must be str, not 'bytes'

It seems like an easy bug to fix, but I donโ€™t know which file has the buggy code.

I hope you can help!

Thanks for the great extension ๐Ÿ‘

Here are more details:

jupyter labextension install --debug @jupyterlab/toc
jupyter labextension install --debug @jupyterlab/toc
Searching ['/PHShome/ks38', '/PHShome/ks38/.jupyter', '/data/srlab/slowikow/src/miniconda2/envs/py3/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
Looking for jupyter_config in /etc/jupyter
Looking for jupyter_config in /usr/local/etc/jupyter
Looking for jupyter_config in /data/srlab/slowikow/src/miniconda2/envs/py3/etc/jupyter
Looking for jupyter_config in /PHShome/ks38/.jupyter
Looking for jupyter_config in /PHShome/ks38
> /data/srlab/slowikow/src/miniconda2/envs/py3/bin/npm pack @jupyterlab/toc
jupyterlab-toc-0.3.1.tgz


   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                     โ”‚
   โ”‚   Update available 5.6.0 โ†’ 6.2.0    โ”‚
   โ”‚     Run npm i -g npm to update      โ”‚
   โ”‚                                     โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Fetching URL: https://registry.npmjs.org/@jupyterlab%2Ftoc
Traceback (most recent call last):

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/labextensions.py", line 71, in start
    ans = self.run_task()

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/labextensions.py", line 100, in run_task
    for arg in self.extra_args

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/labextensions.py", line 100, in <listcomp>
    for arg in self.extra_args

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/commands.py", line 227, in install_extension
    return handler.install_extension(extension)

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/commands.py", line 366, in install_extension
    info = self._install_extension(extension, tempdir)

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/commands.py", line 1138, in _install_extension
    version = self._latest_compatible_package_version(name)

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/commands.py", line 1202, in _latest_compatible_package_version
    metadata = _fetch_package_metadata(self.registry, name, self.logger)

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/site-packages/jupyterlab/commands.py", line 1588, in _fetch_package_metadata
    return json.load(response)

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)

  File "/data/srlab/slowikow/src/miniconda2/envs/py3/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))

TypeError: the JSON object must be str, not 'bytes'


Errored, use --debug for full output:
TypeError: the JSON object must be str, not 'bytes'

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ian-r-rosecommented, Jul 26, 2018

Just opened jupyterlab/jupyterlab#4962 with this fix. Thanks again @slowkow

0reactions
ian-r-rosecommented, Jul 27, 2018

Fixed by jupyterlab/jupyterlab#4962

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: the JSON object must be str, not 'bytes'
I have the following, very basic code that throws; TypeError: the JSON object must be str, not ...
Read more >
The JSON object must be str, bytes or bytearray, not list
The Python "TypeError: the JSON object must be str, bytes or bytearray, not list" occurs when we pass a list to the json.loads()...
Read more >
Python3: TypeError: the JSON object must be str, not 'bytes' #17
json.load() requires str , but HTTPResponse.read() returns bytes. In Python 3.6 it should work, as json.load() has additional logic toย ...
Read more >
PYTHON : TypeError: the JSON object must be str, not 'bytes'
PYTHON : TypeError: the JSON object must be str, not 'bytes ' [ Gift : Animated Search Engine : https://www.hows.tech/p/recommended.html ]ย ...
Read more >
"TypeError: the JSON object must be str, not 'bytes'"
Hi! I'm trying to run GYB on my Synology NAS device, which has Python 3 installed. It seems like GYB should work on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found