What I got now, are two files as following:
Code: Select all
..\addons\source-python\test\test.py
..\addons\source-python\test\classes.py
Now if I want to import classes.py file into my test.py file, this is what I'd do:
Syntax: Select all
from classes import *
Syntax: Select all
#Add import path: ..\addons\source-python\test\
from paths import ADDON_PATH
from sys import path
path.append(ADDON_PATH + "\\test\\")
#Import test classes
from classes import *
...Until I reload the script: sp_reload test
Code: Select all
[SP] Loading "Test"...
[SP] caught an exception:
Traceback (most recent call last):
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "..\addons\source-python\_libs\addons\manager.py", line 35, in __missing__
instance = _LoadedAddon(addon_name)
File "..\addons\source-python\_libs\adodns\manager.py", line 201, in __init__
addon = __import__(addon_name + '.' + addon_name)
ImportError: No module named 'Test.Test'; Test is not a package
[SP] Addon "Test" was unable to be loaded.
Help? :) If I add a new import directory, the script can be loaded once, and works just fine, but if I wanna reload it, everything gets messed up. What am I doing wrong, or am I even doing anything wrong?