First plugin; epic traceback - ImportError - SOLVED

Please post any questions about developing your plugin here. Please use the search function before posting!
statik
Junior Member
Posts: 5
Joined: Fri Feb 19, 2016 7:33 am

First plugin; epic traceback - ImportError - SOLVED

Postby statik » Fri Feb 19, 2016 7:39 am

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.
statik
Junior Member
Posts: 5
Joined: Fri Feb 19, 2016 7:33 am

Postby statik » Fri Feb 19, 2016 8:44 am

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"
statik
Junior Member
Posts: 5
Joined: Fri Feb 19, 2016 7:33 am

Postby statik » Fri Feb 19, 2016 8:56 am

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.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Feb 19, 2016 10:47 am

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.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests