[solved] Loading plugin fails (built-in module name)

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

[solved] Loading plugin fails (built-in module name)

Postby BackRaw » Sat Jun 15, 2019 10:13 pm

Hi,

I just setup my test server and I'm trying to load my udm plugin via

Code: Select all

sp plugin reload udm
from the server's console. It works for CS:S, but for CS:GO it says

Code: Select all

[SP] Cannot load plugin 'udm'. Plugin name cannot be name of a built-in module

Am I doing something wrong or is there actually a module named udm? I don't think so, because it works for CS:S.

Output of sp info:

Code: Select all

sp info

IMPORTANT: Please copy the full output.
--------------------------------------------------------
Checksum      : 2961f20500a1df080ae90ebff179314a
Date          : 2019-06-15 22:36:14.352539
OS            : Windows-7-6.1.7601-SP1
Game          : csgo
SP version    : 690
Github commit : c0e62fa54616e5242f0108cd16a8f2b201fd0b2a
Server plugins:
   00: Source.Python, (C) 2012-2019, Source.Python Team.
SP plugins:
--------------------------------------------------------



Thank you!
Last edited by BackRaw on Tue Jun 25, 2019 5:43 pm, edited 1 time in total.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Loading plugin fails (built-in module name)

Postby L'In20Cible » Sun Jun 16, 2019 2:24 am

You must have an ../udm/udm.py file into a search paths (../Python3/, ../packages/custom/, ../packages/site-packages/, etc.) that is imported before it is found as a plugin and is considered a built-in module.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: Loading plugin fails (built-in module name)

Postby BackRaw » Sun Jun 16, 2019 5:40 pm

Is there a quick way to find that out?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Loading plugin fails (built-in module name)

Postby Ayuto » Sun Jun 16, 2019 6:44 pm

Either look through those directories or load this plugin:

Syntax: Select all

import udm

print(udm.__file__)
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: Loading plugin fails (built-in module name)

Postby BackRaw » Mon Jun 17, 2019 11:30 am

Thanks I'll try that.
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: Loading plugin fails (built-in module name)

Postby BackRaw » Thu Jun 20, 2019 7:23 pm

Okay so I have created a plugin test with the following content:

Syntax: Select all

# ../addons/source-python/plugins/test/test.py

import udm

print(udm.__file__)
The output:

Code: Select all

sp plugin reload test
[SP] Unloading plugin 'test'...
[SP] Successfully unloaded plugin 'test'.
[SP] Loading plugin 'test'...
Z:\srcds\Windows\csgo\csgo\addons\source-python\plugins\udm\__init__.py
[SP] Successfully loaded plugin 'test'.

Everything seems fine, there's nothing called udm before my plugin. But the built-in module error still occurs after loading up udm.

Just to clarify, Z: is a network share. Is that maybe causing the error? But then again, why does it work for CS:S?

Edit: manually searching for 'udm' from inside my server directory Z:\srcds\Windows\csgo it only shows my plugin's files and nothing more.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Loading plugin fails (built-in module name)

Postby satoon101 » Thu Jun 20, 2019 8:24 pm

That message will be printed if the following conditional is met:
https://github.com/Source-Python-Dev-Te ... er.py#L181

Add some debug messages in there before the 'raise' statement to see what the values of 'spec', 'spec.origin' (if spec is not None), and 'plugin.file_path' are.
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Re: Loading plugin fails (built-in module name)

Postby BackRaw » Tue Jun 25, 2019 5:35 pm

I've added

Syntax: Select all

print(f'\n\nspec: {spec}\n\nplugin.file_path: {plugin.file_path}\n\n')
to line 182 in plugins/manager.py and the output is:

Code: Select all

[SP] Unloading plugin 'udm'...
[SP] Unable to unload plugin 'udm' as it is not currently loaded.
[SP] Loading plugin 'udm'...

spec: ModuleSpec(name='udm.udm', loader=<_frozen_importlib_external.SourceFileLoader object at 0x1955B210>, origin='Z:\\srcds\\Windows\\csgo\\csgo\\addons\\source-python\\plugins\\udm\\udm\\__init__.py', submodule_search_locations=['Z:\\srcds\\Windows\\csgo\\csgo\\addons\\source-python\\plugins\\udm\\udm'])

plugin.file_path: Z:\srcds\Windows\csgo\csgo\addons\source-python\plugins\udm\udm.py

[SP] Cannot load plugin 'udm'. Plugin name cannot be name of a built-in module

Oh my God, wait a second...

Edit: No wonder, I had a folder udm inside my udm folder which had another udm folder inside it. What the hell was that lol... Anyway I messed up my symlinking. I'll try to recover it now.

Edit 2: Works now. Never stay up too long and try to symlink your way through I guess... Thanks for the help!!

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 26 guests