netbox-community / netbox-plugin-tutorial

A tutorial on building custom plugins for NetBox v3.2+
89 stars 46 forks source link

Unable to import plugin netbox_access_lists: Module not found. #33

Open bytelock-id opened 5 months ago

bytelock-id commented 5 months ago

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 commented 5 months ago

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

peteeckel commented 5 months ago

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 commented 5 months ago

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].

bytelock-id commented 5 months ago

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.

amyers1616 commented 5 months ago

@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

MohammadMortezaie commented 4 months ago

I have same Issue

Wigmund commented 4 months ago

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'
peteeckel commented 4 months ago

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