There is one thing, that I do not understand.
Why does this
import scipy # happens with several other modules, too. I took scipy as an example now...
matrix = scipy.sparse.coo_matrix(some_params)
produce this error:
AttributeError: 'module' object has no attribute 'sparse'
This happens because the
scipymodule doesn’t have any attribute namedsparse. That attribute only gets defined when youimport scipy.sparse.Submodules don’t automatically get imported when you just
import scipy; you need to import them explicitly. The same holds for most packages, although a package can choose to import its own submodules if it wants to. (For example, ifscipy/__init__.pyincluded a statementimport scipy.sparse, then thesparsesubmodule would be imported whenever you importscipy.)