How to import a certain module from a package

I was trying to import a module from a package to illustrate,

using package.ABC: submodule1, submodule2, ...
But then when I applied tests to it, it returns:
UndefVarError: ABC not defined.

How do I go about resolving this issue?

Thank you in advance!

Something like this perhaps?

import package
import package.ABC
using package.ABC: submodule1, submodule2, ...
1 Like

I don’t think it works. The problem with it might be that it is one part of the package that I myself am trying to develop. So the test file is one place and the ABC file is in another place, wherein the submodules1, are located

What step are you stuck on? Did you include the files into your package? Is your package on your LOAD_PATH? Did you dev your package into your environment? The way modules work here is quite different than the way they work in Python.

@mkitti Ok, so I noticed that the file is a module from another folder of the same package, so one detour I took, was to import() the module.

So explicitly, what I did was:

using .ABC : submodule1, submodule2, etc.

I wouldn’t claim that this is the most efficient way, and it could possibly be a bad practice to import codes like this. Is it?

That syntax is weird. I suspect you meant something like this:

using .ABC : submodule1, submodule2, etc.

However, I’m quite confused about your directory structure. What is the current directory? Did you start julia with julia --project=. to load the current directory as the active project environment?

See Code Loading · The Julia Language