Page 1 of 1

First plugin; epic traceback - ImportError - SOLVED

Posted: Fri Feb 19, 2016 7:39 am
by statik
Picking up Source.Python for the first time...Not going well :(

Error message:

Code: Select all

sp load apdm
[SP] Loading plugin 'apdm'...

[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/packages/source-python/plugins/manager.py', line 71, in __missing__
    instance = self.instance(plugin_name, self.base_import)
  File '../addons/source-python/packages/source-python/plugins/instance.py', line 82, in __init__
    self._plugin = import_module(import_name)

ImportError: No module named 'apdm.apdm'; 'apdm' is not a package


Plugin Code:

Code: Select all

def load():
    print('Plugin has been loaded successfully!')

def unload():
    print('Plugin has been unloaded successfully!')


Current Source.Python version: 252

Followed the installation steps and everything seems to have gone swimmingly there. Have made sure all file permissions are good. Have tried searching, but didn't see any other instance of this error.

Thanks in advance!

EDIT: I forgot to mention the game is HL2MP running on Debian 7.9/WHeezy on a VPS that I would presume to be para-virtualized.

Posted: Fri Feb 19, 2016 8:44 am
by statik
After thinking about the error over lunch, I decided to try saving the file as __init__.py and it worked! So either there is a bug in play here, or the Getting Started tutorial should reflect that we save our main plugin file as __init__.py instead of "name-of-plugin.py"

Posted: Fri Feb 19, 2016 8:56 am
by statik
I worked it out. I had initially created my plugin file in the root plugins folder before I realized I needed to create a directory first....Then I just "saved as" and never deleted the old file. Everything is working as-expected now.

Posted: Fri Feb 19, 2016 10:47 am
by Ayuto
Hello and welcome to SP! I'm glad you solved the issue on your own.

I guess we should make sure that no *.py file with the same name like a directory exists in the plugins folder when loading the plugin.