[Solved] NameError: name ‘json’ is not defined

Trying to import Json, my command is pip install json.
I’m working on windows 8.1

The error i’m getting in command prompt is

Could not find a version that satisfies the requirements json <from versions:>

No matching distribution found for json.

and the error i’m getting on pycharm is

NameError: name 'json' is not defined

I tried importing numpy and it worked just fine .
I also did check Pip “Could not find a that satisfies the requirement”
and Could not find a version that satisfies the requirement <package>

Edit : Referred also to this link Python 3.5.1 : NameError: name ‘json’ is not defined and getting an error that sudo is not recognized

Enquirer: Jimmy


Solution #1:

If it’s not defined in your code, you need to import it. This is exactly the same as any name in Python; you can’t use something until you have defined it.

import json
Respondent: Jimmy

Solution #2:

Use the command as simplejson instead of json like below,

pip install simplejson

If the above command also throwing an error Use the following command

easy_install simplejson

easy_install works sometimes if pip cannot serve the request.

Respondent: Daniel Roseman

Solution #3:

I have also encountered a similar issue, pip failing to install json and math modules (using python 3.x).
Finally, I discovered that some modules you simply do not have to install – they are already BUILT-IN. 🙂
Of course, you still have to add “import json” at the top of your .py file.
Hope this helps somebody.

Respondent: SBN AB

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published. Required fields are marked *

New ride at Perth's Adventure World a ‘swing on steroids’ - Australasian Leisure Management npp pharma the truth about anabolic steroid drugs and professional sports