OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

response.json() works fine in WSL but not in cmd or Linux Terminal

  • Thread starter Thread starter user25689293
  • Start date Start date
U

user25689293

Guest
I have this Python code:

Code:
.
.
.
url = 'https://myurl.com'
response = requests.post(url, headers=headers, json=data)
json_response = response.json()

when I run it in WSL it works fine but when I run it in Linux server or windows CMD it gives this error:

Code:
Traceback (most recent call last):
  File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\fish\Desktop\test.py", line 68, in <module>
    json_response = response.json()
                    ^^^^^^^^^^^^^^^
  File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Why it works fine in WSL and shows this error in windows or Linux?

Python version in WSL: 3.10.12
Python version in Windows: 3.12.0
Python version in Linux: Python 3.10.12
<p>I have this Python code:</p>
<pre><code>.
.
.
url = 'https://myurl.com'
response = requests.post(url, headers=headers, json=data)
json_response = response.json()
</code></pre>
<p>when I run it in WSL it works fine but when I run it in Linux server or windows CMD it gives this error:</p>
<pre><code>Traceback (most recent call last):
File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\fish\Desktop\test.py", line 68, in <module>
json_response = response.json()
^^^^^^^^^^^^^^^
File "C:\Users\fish\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
</code></pre>
<p>Why it works fine in WSL and shows this error in windows or Linux?</p>
<p>Python version in WSL: 3.10.12<br />
Python version in Windows: 3.12.0<br />
Python version in Linux: Python 3.10.12</p>
 

Latest posts

Top