I would like to use scipy.spatial.distance.cosine in my code. I can import the spatial submodule if I do something like import scipy.spatial<
Importing a package does not import submodule automatically. You need to import submodule explicitly.
For example, import xml does not import the submodule xml.dom
>>> import xml
>>> xml.dom
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'dom'
>>> import xml.dom
>>> xml.dom
There's an exception like os.path. (os module itself import the submodule into its namespace)
>>> import os
>>> os.path