Macros work on Julia syntax, that is too Python, hence the deviation in usage. Hypothetically, arbitrary syntax could be written in the string and parsed by a function or string literal macro, but that didn’t happen.
From the docstring: “@pyimport module as name is equivalent to const name = pywrap(pyimport("module")).” The pywrap is needed to make a Julia module with member access, which the pyimport output lacks. norm is not a Python module however, stats is.
julia> norm = pyimport("scipy.stats.norm")
ERROR: PyError (PyImport_ImportModule
The Python package scipy.stats.norm could not be imported by pyimport. Usually this means
that you did not install scipy.stats.norm in the Python version being used by PyCall.
I’d hazard a guess at the equivalent to from scipy.stats import norm being const norm = pywrap(pyimport("scipy.stats")).norm. But I wouldn’t want to lose the Julia module without a reference, I don’t think a repeat call is as smooth as another import statement in Python.