Psy-Fer / SquiggleKit

SquiggleKit: A toolkit for manipulating nanopore signal data
MIT License
122 stars 23 forks source link

Changes to support Python3 (with backward compatibility I think) #6

Closed nodrogluap closed 5 years ago

nodrogluap commented 5 years ago

I had trouble getting all the dependencies to work in Python 2.7, so thought I'd do a few edits to support Python 3(.7) as all the dependencies worked nicely in conda (i.e. easy install with no sudo privilege). YMMV. I think the changes work in Python 2 as well but please check as I couldn't fully test Python 2.7 functionality.

Psy-Fer commented 5 years ago

Hey there. Python 3 compatibility was part of my next larger update. This is however pretty damn great. I'll merge in what I can and test the compatibility.

As a note around sudo use, pip is able to install anything locally in any environment. I was assuming any user that knew how to use environments, would know this. Perhaps I should be a little more verbose about that.

nodrogluap commented 5 years ago

Right, I use pip a lot with user install option, but underlying Tk stuff seemed to not resolve properly.

-bash-4.2$ /usr/bin/python2.7 SquigglePlot.py Traceback (most recent call last): File "SquigglePlot.py", line 8, in import matplotlib.pyplot as plt File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 115, in _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() File "/usr/lib64/python2.7/site-packages/matplotlib/backends/init.py", line 62, in pylab_setup [backend_name], 0) File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in from . import tkagg # Paint image to Tk photo blitter extension. File "/usr/lib64/python2.7/site-packages/matplotlib/backends/tkagg.py", line 5, in from six.moves import tkinter as Tk File "/usr/lib/python2.7/site-packages/six.py", line 203, in load_module mod = mod._resolve() File "/usr/lib/python2.7/site-packages/six.py", line 115, in _resolve return _import_module(self.mod) File "/usr/lib/python2.7/site-packages/six.py", line 82, in _import_module import(name) ImportError: No module named Tkinter

And pip doesn’t seem to know about tkinter. Saw use of the six module, so decided to try Python 3. :-)

On Mar 18, 2019, at 5:00 PM, James Ferguson notifications@github.com<mailto:notifications@github.com> wrote:

Hey there. Python 3 compatibility was part of my next larger update. This is however pretty damn great. I'll merge in what I can and test the compatibility.

As a note around sudo use, pip is able to install anything locally in any environment. I was assuming any user that knew how to use environments, would know this. Perhaps I should be a little more verbose about that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Psy-Fer/SquiggleKit/pull/6#issuecomment-474133799, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACPep2h21Tn1FOxeHNZKVhEZTJrOSZW0ks5vYBqVgaJpZM4b6gRw.

Psy-Fer commented 5 years ago

Should be fine with any python 2.7+ environment, and has been pretty straight forward on all machines we have been using here, laptops running windows, mac, ubuntu, as well as our CentOS server.

Do you have any more specific information around what didn't work?

nodrogluap commented 5 years ago

It turns out that Python Tk support in CentOS 7 is a Hot Mess. Tk support is not included in the base OS python install for 2.7.5. Running with escalated privilege "yum install python27-tkinter" installed a bunch of stuff, but amazingly does not have a dependency on the base tkinter package. So you also need to run "yum install tkinter". Then it works.

Psy-Fer commented 5 years ago

Ahh. Yea Tk isn't a requirement for SquiggleKit as far as i'm aware, unless it's hidden away in matplotlib somewhere

nodrogluap commented 5 years ago

It appears to be the default backend for matplotlib as per the traceback. You could manually override to use matplotlib.use('FooAgg') with WXAgg , GTKAgg , QT4Agg , QT5Agg, etc. but not sure that's going to be any less of a headache for some user. Nothing's universal probably?

nodrogluap commented 5 years ago

Tk is probably still the best bet, with the caveats for CentOS 7. I was just too lazy to figure it out before. :-)

Psy-Fer commented 5 years ago

Hmm interesting. I didn't have any issues with tkinter that I remember. Looks like I need to spin up another fresh environment and see if I can sort that out.

Thanks so much for the feedback so far.

Psy-Fer commented 5 years ago

This was awesome and I took this add in just some raw error message. I'll probably clean this up in a similar way to what you have done in a refactor. I'll chuck you into my acknowledgements cause this along with my gzip iohandling was what I needed to change to make it compatible with all python.