Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

ImportError: No module named patterns.extension #8

Closed
JohnnyUSA opened this issue Feb 24, 2016 · 18 comments
Closed

ImportError: No module named patterns.extension #8

JohnnyUSA opened this issue Feb 24, 2016 · 18 comments

Comments

@JohnnyUSA
Copy link

Hi guys and thanks for this wonderful script.

Worked fine for me until 2 days ago when it seems to fail with this error:

info Sat Feb 20 2016 00:08:04 videosort: ImportError: No module named patterns.extension 
info Sat Feb 20 2016 00:08:04 videosort: import guessit.patterns.extension 
info Sat Feb 20 2016 00:08:04 videosort: File "/opt/nzbget/scripts/videosort/videosort.py", line 254, in <module> 
info Sat Feb 20 2016 00:08:04 videosort: Traceback (most recent call last): 

Python version is:

root@xxx-nas:~# python -V
Python 2.7.9

I've tried to google around and no fix.. you're my last hope.

Thanks in advance!

@hugbug
Copy link
Member

hugbug commented Feb 25, 2016

Replied you on forum.

@JohnnyUSA
Copy link
Author

Hi and thanks for your reply, your 2nd suggestion saved me:

Replacing
sys.path.append(dirname(__file__) + '/lib')
with
sys.path.insert(1, dirname(__file__) + '/lib')
in videosort.py, did the trick. Script is working now.

However, i still get a warning:
videosort: /opt/nzbget/scripts/videosort/lib/guessit/__init__.py:23: UserWarning: Module guessit was already imported from /opt/nzbget/scripts/videosort/lib/guessit/__init__.pyc, but /usr/local/lib/python2.7/dist-packages is being added to sys.path

Something to worry about? Cheers!

@hugbug
Copy link
Member

hugbug commented Feb 25, 2016

As long as it works I think you can safely ignore the message.

@JohnnyUSA JohnnyUSA reopened this Feb 25, 2016
@JohnnyUSA
Copy link
Author

Ok thanks, closing it for now ;)

@mourningsun75
Copy link

Hi,

Replacing
sys.path.append(dirname(file) + '/lib')
with
sys.path.insert(1, dirname(file) + '/lib')

for me it is not working. :-(

Now i got the following error:

VideoSort: ValueError: A 0.7-series setuptools cannot be installed with distribute. Found one at /usr/local/lib/python2.7/dist-packages

@mourningsun75
Copy link

It works when i uninstall guessit, but guessit is required by other other software

@hugbug
Copy link
Member

hugbug commented Apr 14, 2016

Your system version of guessit should not be used at all. Check again if the videosort.py were edited correctly with "sys.path.insert". And of course make sure you have the whole videosort-folder including lib-subdirectory and not just videosort.py.

@mourningsun75
Copy link

Test 1:

sys.path.append(dirname(__file__) + '/lib')
#sys.path.insert(1, dirname(__file__) + '/lib')

Error:
VideoSort: ImportError: No module named patterns.extension

Test 2:

#sys.path.append(dirname(__file__) + '/lib')
sys.path.insert(1, dirname(__file__) + '/lib')

Error:

VideoSort: /home/xxx/nzbget/plugins/videosort/lib/guessit/__init__.py:23: UserWarning: Module guessit was already imported from /home/xxx/nzbget/plugins/videosort/lib/guessit/__init__.pyc, but /usr/local/lib/python2.7/dist-packages is being added to sys.path

VideoSort: ValueError: A 0.7-series setuptools cannot be installed with distribute. Found one at /usr/local/lib/python2.7/dist-packages

@mourningsun75
Copy link

"And of course make sure you have the whole videosort-folder including lib-subdirectory and not just videosort.py." -> Checked, everthing is there

@hugbug
Copy link
Member

hugbug commented Apr 14, 2016

Is this an error at all? Not a warning? I don't see call stack printed.

I'm afraid I can't help you more here as I'm not very experienced with python. I have general debug skills but I need to put my hands on the system to try things.

@mourningsun75
Copy link

Here is the stack

Thu Apr 14 14:41:10 2016        INFO    nzbget 16.4 daemon-mode
Thu Apr 14 14:41:10 2016        INFO    Scheduler: pausing download
Thu Apr 14 14:41:24 2016        INFO    XYZ returned from history back to download queue
Thu Apr 14 14:41:24 2016        INFO    Queueing XYZ for post-processing
Thu Apr 14 14:41:24 2016        INFO    Cleaning up XYZ
Thu Apr 14 14:41:24 2016        INFO    Nothing to cleanup for XYZ
Thu Apr 14 14:41:25 2016        INFO    Executing post-process-script videosort/VideoSort.py for XYZ
Thu Apr 14 14:41:25 2016        INFO    VideoSort: /home/xxx/nzbget/plugins/videosort/lib/guessit/__init__.py:23: UserWarning: Module guessit was already imported from /home/xxx/nzbget/plugins/videosort/lib/guessit/__init__.pyc, but /usr/local/lib/python2.7/dist-packages is being added to sys.path
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   import pkg_resources
Thu Apr 14 14:41:25 2016        INFO    VideoSort: Traceback (most recent call last):
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/VideoSort.py", line 254, in <module>
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     import guessit
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/lib/guessit/__init__.py", line 23, in <module>
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     import pkg_resources
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/lib/pkg_resources.py", line 2841, in <module>
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     add_activation_listener(lambda dist: dist.activate())
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/lib/pkg_resources.py", line 710, in subscribe
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     callback(dist)
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/lib/pkg_resources.py", line 2841, in <lambda>
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     add_activation_listener(lambda dist: dist.activate())
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/lib/pkg_resources.py", line 2273, in activate
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     self.insert_on(path)
Thu Apr 14 14:41:25 2016        INFO    VideoSort:   File "/home/xxx/nzbget/plugins/videosort/lib/pkg_resources.py", line 2374, in insert_on
Thu Apr 14 14:41:25 2016        INFO    VideoSort:     "with distribute. Found one at %s" % str(self.location))
Thu Apr 14 14:41:25 2016        INFO    VideoSort: ValueError: A 0.7-series setuptools cannot be installed with distribute. Found one at /usr/local/lib/python2.7/dist-packages
Thu Apr 14 14:41:25 2016        ERROR   Post-process-script videosort/VideoSort.py for XYZ failed (terminated with unknown status)
Thu Apr 14 14:41:25 2016        INFO    Executing post-process-script Logger.py for XYZ
Thu Apr 14 14:41:25 2016        INFO    Post-process-script Logger.py for XYZ successful
Thu Apr 14 14:41:25 2016        INFO    Executing post-process-script EMail.py for XYZ
Thu Apr 14 14:41:25 2016        DETAIL  EMail: Script successfully started
Thu Apr 14 14:41:25 2016        DETAIL  EMail: Sending E-Mail
Thu Apr 14 14:41:27 2016        INFO    Post-process-script EMail.py for XYZ successful
Thu Apr 14 14:41:27 2016        INFO    Collection XYZ added to history

@mourningsun75
Copy link

The combination:

sudo pip uninstall guessit

and

sys.path.append(dirname(__file__) + '/lib')

works perfect.

But not for other tools and scripts

@hugbug
Copy link
Member

hugbug commented Apr 14, 2016

Make another: use "sys.path.insert" and delete file "videosort/lib/pkg_resources.py".

@mourningsun75
Copy link

Same Stack

@hugbug
Copy link
Member

hugbug commented Apr 14, 2016

Same Stack

I don't believe you 👮
Post it.

@mourningsun75
Copy link

you are right!

know it seems to work!

@hugbug
Copy link
Member

hugbug commented Apr 14, 2016

TODO:

  • use "insert" instead of "append";
  • use system "pkg_resources.py" and fall back to "lib/pkg_resources.py" only if a system module doesn't exist.

@hugbug
Copy link
Member

hugbug commented Jun 22, 2017

DONE:

  • use "insert" instead of "append";

TODO:

  • use system "pkg_resources.py" and fall back to "lib/pkg_resources.py" only if a system module doesn't exist.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants