-1

I installed python with anaconda with my computer and I need to import the JSON library.

I learned that JSON is part of the standard library of PYthon, so I am surprised that actually it is not the case with anaconda:

see: https://docs.anaconda.com/anaconda/packages/py3.7_win-64/

import os
import pandas as pd
import shutil
import datetime
import numpy
import xml.etree.ElementTree as ET
import JSON

result:

----> 7 import JSON

ModuleNotFoundError: No module named 'JSON'

I tried to install JSON with pip at no luck. And I see that in the list of Anaconda packages ther is a "JSONschema", but I rather stick to the basics.

but what strickes me the most is that a package that is supposed to be part of the standard library it is actually NOT under Anaconda. Is that right?

How would you advise me to proceed? Is it acually possible to install JSON in/with Anaconda, JSON not being part ot the anaconda package list?

thanks

Note the reason to stick to basic libraries is that I am working in an enterprise environement with proxis and I would like others not to have to install any pacages to use my code -we are not a software company-. thanks.

JFerro
  • 3,203
  • 7
  • 35
  • 88

3 Answers3

2

Be careful with lower and upper case.... You might end up spending some hours like me trying to solve the most stupid problem ever.

the name of the package is json not JSON. lower or upper letter matters

import json

is the solution

JFerro
  • 3,203
  • 7
  • 35
  • 88
2

My anaconda root environment does not list json as a package, yet I can import it. This means it is part of the base Python library and does not need to be installed anymore.

brethvoice
  • 350
  • 1
  • 4
  • 14
  • Apparently this is one surefire way to tell whether a package is part of the standard library for your version of Python: try to import it despite it not showing up in Anaconda (or your package manager of choice) as an installed package. If that works, then you are golden! – brethvoice Feb 26 '20 at 12:35
  • That is not a surefire way to tell a package is STL. 3rd party packages still can be installed and made available by different means, system wide or for given user or python instance. Consulting [docs](https://docs.python.org/3/library/index.html) would be quite safe way to tell. – Ondrej K. Feb 26 '20 at 12:57
  • @OndrejK. I appreciate the link! It makes it clear that the STL is only updated with major version changes (except for beta/most recent stable releases, which are listed with minor/sub-version numbers). – brethvoice Feb 26 '20 at 13:45
1

You have to install json package in anaconda.

conda install -c jmcmurray json
Asier Gomez
  • 6,034
  • 18
  • 52
  • 105