[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
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.
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 works sometimes if pip cannot serve the request.
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.