Skip to content Skip to sidebar Skip to footer

Installed Python Script Cannot Import Package Modules

I have created a Python package with the following directory structure: / LICENSE MANIFEST.IN README.rst VERSION docs/ multitool/ __init__.py core/ __init_

Solution 1:

First off, when you install the package you are importing core without identifying it is being apart of the multitool package. So:

import core

should be,

from multitool import core

That way the interpreter knows the module to import core from.

[Edit]

As for the directory structure of the installed package, scripts need to go into a separate directory from the module itself. The way the shown directory structure is Distutils will install the script you named into both a place your system looks for executables as well as in the package itself, which is likely where all the confusion is coming from.


Solution 2:

import multitool

class HashTool(multitool.core.classes.CLITool):

Importing a package does not import its subpackages and submodules. Try this:

import multitool.core.classes

class HashTool(multitool.core.classes.CLITool):

Post a Comment for "Installed Python Script Cannot Import Package Modules"