Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification script returned exit code 1 and output "Traceback (most recent call last) #72

Closed
SuissoNaBisso9 opened this issue Nov 18, 2020 · 21 comments
Labels

Comments

@SuissoNaBisso9
Copy link

Question

hey ! trying to set up the notify script on SABnzbd for Discord.

Well installed all files on home/user/SABnzbd/scripts
Did a chmod +x to make them executable

Also in "parameters" field I've set my Discord webhook URL.

But on SABnzbd when triggering the test notification i get the following error :
Notification script returned exit code 1 and output "Traceback (most recent call last): File "/home/suissonabisso/SABnzbd/scripts/Notify.py", line 174, in from nzbget import SCRIPT_MODE ImportError: No module named nzbget "

What I've missed ?

Thank you !

@caronc
Copy link
Owner

caronc commented Nov 18, 2020

You're just missing the plugins that this script relies on:

pip install -r requirements.txt

#alternatively this should work too:
pip install pynzbget

@SuissoNaBisso9
Copy link
Author

Actually I did install all requirements and tested this 'pip install pynzbget' and it also said requirements already satisfied.
But still SABnzdbd is returning same error code

@caronc
Copy link
Owner

caronc commented Nov 18, 2020

Strange, is SABnzbd running in a Docker container? These commands need to be ran in there if so.

What is your os? Also, what version of Python and SABnzbd are you using?

@SuissoNaBisso9
Copy link
Author

SuissoNaBisso9 commented Nov 18, 2020

No docker and using ubuntu 18.04
SAbnzbd version : 3.1.0RC3 [6aef50d]
Python : python 3.8.2

@caronc
Copy link
Owner

caronc commented Nov 19, 2020

I wonder if this is an issue with multiple python versions. Can you try same pip commands, but use pip3 instead?

@SuissoNaBisso9
Copy link
Author

Already did too, all requirements satisfied as well

@caronc
Copy link
Owner

caronc commented Nov 19, 2020

The last few things you could try is manually running the script yourself to see if you get the same error:

# Just to test things:
python /path/to/sabnzbd/sabnzbd-notify.py complete 'Hello' 'World' <Apprise URL here>

If that works then there is something unique about your SABnzbd installation; the environment it runs in is completely different the the one you're in when you call the script. Perhaps a Python virtual env?

If that doesn't work, then the problem gets a bit easier to solve because at least it's reproducible

@SuissoNaBisso9
Copy link
Author

So just tested and getting the same error code :
image

@caronc
Copy link
Owner

caronc commented Nov 20, 2020

Sorry for the long delay; It seems like your pip repository got damaged or corrupted some how. I would just uninstall pynzbget and put it back in. Hopefully the system will pick it up then:

pip uninstall pynzbget
pip install pynzbget

@SuissoNaBisso9
Copy link
Author

Hey
Just tried that but still getting the same error message, both from SABnzbd and by testing directly in CLI

@caronc
Copy link
Owner

caronc commented Nov 22, 2020

that's really weird, there is definitely something wrong with your environment 🙁 .

i verified the script works correctly by doing the following myself:

# create a new virtual environment to test with:
python3 -m venv test-nzb-notfify

# Change into our new directory
cd  test-nzb-notfify

# Activate our virtual environment
source bin/activate

# Install pynzbget
pip install pynzbget

# test that the environment variables are importable:
python -c "from nzbget import SCRIPT_MODE" && echo "OKAY" || or echo "Fail"

The above outputs OKAY every-time for me; i get no import error. If installation the library and reloading it doesn't work then there is something that is obstructing your Python library of installed packages.

Another possibility is there is another Python library called nzbget installed into your library and when your system calls from nzbget import SCRIPT_MODE it can't find it.

You could check inside your SABnzbd installation directory and make sure there is no directory called nzbget with an __init__.py file in it... OR a file called nzbget.py. The other thing you could do (to test this theory) is open up a python console (just type python) and do the following:

# in a python terminal:
import nzbget

# If the above does not give you an error then something was found and imported...

# Test that it is a module:
print(type(nzbget))
# expect output like: <class 'module'>

# Now find out where this module came from:
print(nzbget.__file__)

# Verify that the path that is outputed is indeed where you installed pynzbget;  My guess is this
# is not valid package.  Or if it is (that's fine too), but it isn't the one you want :slightly_smiling_face: 

@SuissoNaBisso9
Copy link
Author

Hi

Thanks for chekcing further

So actually looking in my SABnzbd directory I found another file 'init.py'
First one is there /home/user/SABnzbd/sabnzbd/init.py
the second is the one from your script here /home/user/SABnzbd/scripts/Notify/init.py

Then I aslo ran a python terminal with first command and it gave me this :

(1:355)# python
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import nzbget
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named nzbget

@caronc
Copy link
Owner

caronc commented Nov 22, 2020

So i can see one problem already; up above, you said:

SAbnzbd version : 3.1.0RC3 [6aef50d]
Python : python 3.8.2

SABnzbd requries Python v3. so this all makes sense. But your last comment shows you running the test using Python v2.7 (which operates in a completely different realm and requires a separate pip installation for it).

In a situation where you have both Python v2 and v3, you need to use pip3 or pip to separate the calls. You also need to use the binary python3 and python (for v2 references).

Python 2.7.17 (default, Sep 30 2020, 13:38:04)

Is it possible that pynzbget is properly installed in your Python 3 environment and both you and your SABnzbd is running in a Python 2 environment? Another issue that can cause problems is stale .pyc files. You could try stopping SABnzbd and removing the .pyc files if any were created (this is safe; don't worry). Something like:

find /path/to/your/sabnzbd/installation -type f -name '*.pyc' --delete

@SuissoNaBisso9
Copy link
Author

Not sure I'm doing this right ?
image

@SuissoNaBisso9
Copy link
Author

and yes for Python that's weir, but SABnzbd says I'm running this :
image

I'm running the seedbox script Quickbox Pro FYI, and they use different python version as I understood, for example for Tautulli I had to manually change the config file to run with Python 3 and then run some scripts.

@caronc
Copy link
Owner

caronc commented Nov 23, 2020

So the catch is, you can't just change to use the python 3 binary you have installed on the Quickbox Pro setup. You need to change your environment as well so your virtually sitting in the same world as SABnzbd is.

I don't know much about Quickbox Pro or how SABnzbd gets installed into it with a custom version of Python. You'll need to mimic it's environment variables and stuff since entries like PYTHONPATH for example can cause your application to look in one location for all of it's packages while you install it in another. Do you have the instructions or tricks you did to install SABnzbd? Does Quickbox just run natively on a server? Or is it like managing docker containers for you? It might be setting up virtual environments so that some applications don't step on others?

@SuissoNaBisso9
Copy link
Author

Hi

Thanks for checking all this, I'll share this case with Quickbox Pro support team because honestly I don't have so much information abaout hw it works etc...
Will keep you updated if I have some progress.

Thank you for the support again !

@Squiggles4321
Copy link

Hey,

If you have python3 on your system as well, but python2 is still the system default just edit sabnzbd-notify.py and Notify.py and change:

#!/usr/bin/env python
to
#!/usr/bin/env python3

It is what I had to do in my multi-python system. Working fine now when it invokes python3.

-Squigs

@SuissoNaBisso9
Copy link
Author

Hey @Squiggles4321
Just tried that but i'm stil getting the same errors as usual.
Will have to check further with Quickbox Pro support team

Thanks !

@Squiggles4321
Copy link

Very specific to your environment then. Good luck.

-Squigs

@caronc
Copy link
Owner

caronc commented Mar 13, 2022

I'm closing this ticket off; unfortunately it's 100% related to the python installation and it's configured environment

@caronc caronc closed this as completed Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants