netbox-plugin-tutorial icon indicating copy to clipboard operation
netbox-plugin-tutorial copied to clipboard

Unable to import plugin netbox_access_lists: Module not found.

Open bytelock-id opened this issue 1 year ago • 9 comments

After following the instructions about 45 times. Each time resulting with the same issue. After restarting netbox, I'm seeing the error in the logs. "Unable to import plugin netbox_access_lists" and it fails to start.

  1. I am running the virtual environment. Using: source /opt/netbox/venv/bin/activate
  2. I am installing the plugin. I have tried the following installation methods. (pip install --editable .) from the plugin directory as well as (python3 setup.py develop)
  3. I have checked out step 001 to make sure I didn't have a typo.
  4. I have the latest vanilla netbox.
  5. The configuratioon.py does have the correct named plugin in it.
  6. I have the most recent versions of everything Python3, Postgres, Redis, Nginx, available to Ubuntu 22 and I can confirm the vanilla version runs fine before adding any plugins.

Somethings not installing or adding correctly. etc.

bytelock-id avatar Mar 26 '24 15:03 bytelock-id

The instructions I'm referring to are the how to create a plugin with Netbox.

bytelock-id avatar Mar 28 '24 12:03 bytelock-id

I'm afraid you'll need to document your steps more thoroughly. Nobody can actually reproduce the problem with that kind of vague information - and I know that the instructions worked for me as I created a test plugin for issue https://github.com/netbox-community/netbox/issues/15194 not so long ago following exactly the same instructions you're apparently stumbling over.

peteeckel avatar Mar 28 '24 12:03 peteeckel

That said, I'll venture a guess: Are you seeing this:

django.core.exceptions.ImproperlyConfigured: Unable to import plugin netbox_access_list: Module not found. Check that the plugin module has been installed within the correct Python environment.

In that case the plugin is not installed in your virtual environment. Did you use sudo for the pip install? That doesn't work well with a venv being activated with activate. And it is properly documented.

If the above assumptions are correct (remember, I'm just guessing because you didn't provide sufficient information), try

sudo /opt/netbox/venv/bin/python3 -m pip install -e [path]

with the path you checked out the plugin to instead of [path].

peteeckel avatar Mar 28 '24 12:03 peteeckel

I'm afraid you'll need to document your steps more thoroughly. Nobody can actually reproduce the problem with that kind of vague information - and I know that the instructions worked for me as I created a test plugin for issue netbox-community/netbox#15194 not so long ago following exactly the same instructions you're apparently stumbling over.

I think we can just close this issue. I really don't care at this point anymore and I'm not going to get into some pissing match.

bytelock-id avatar Mar 28 '24 12:03 bytelock-id

@bytelock-id -- I had the same issue & this helped me fix it. I too was using sudo to compile the plugin and had the module not found error. https://github.com/netbox-community/netbox-plugin-tutorial/issues/26#issuecomment-1585442656

amyers1616 avatar Mar 28 '24 20:03 amyers1616

I have same Issue

MohammadMortezaie avatar Apr 21 '24 03:04 MohammadMortezaie

Any ideas why I'm getting this error on this command on the last step of Step01 (everything else seemed to go smoothly):

/opt/netbox/netbox$ sudo python3 manage.py runserver
Traceback (most recent call last):
  File "/opt/netbox/netbox/manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

Wigmund avatar Apr 26 '24 22:04 Wigmund

Yes.

You did not activate the virtual environment and did not use the full path of the python3 interpreter within the virtual environment.

At least one of the above is necessary.

With sudo, you need to do the latter:

sudo /opt/netbox/venv/bin/python3 /opt/netbox/netbox/manage.py runserver

peteeckel avatar Apr 26 '24 22:04 peteeckel