Article
· 4 hr ago 1m read

Avoid to use package named "code" with embedded python methods using [Language = python]

Hello,

as it took me some time to figure out what's wrong, I would like to share this experience, so that you do not fall into the same trap.

I've just noticed that if you name your package "code" (all lowercase), in a class using some embedded python using [Language = python], you'll face the <THROW> *%Exception.PythonException <PYTHON EXCEPTION> 246 <class 'ModuleNotFoundError'>: No module named 'code.basics'; 'code' is not a package

Class code.basics Extends %RegisteredObject
{

ClassMethod Welcome() As %Status [ Language = python ]
{
print('Welcome!')
return True
}
}
IRISAPP>w ##class(code.basics).Welcome()

W ##CLASS(code.basics).Welcome()
^
<THROW> *%Exception.PythonException <PYTHON EXCEPTION> 246 <class 'ModuleNotFoundError'>: No module named 'code.basics'; 'code' is not a package

It works well with "Code" :

Class Code.basics Extends %RegisteredObject
{

ClassMethod Welcome() As %Status [ Language = python ]
{
print('Welcome!')
return True
}
}
IRISAPP>w ##class(Code.basics).Welcome()
Welcome!
1
Discussion (0)1
Log in or sign up to continue