nengo / nengo-extras

Extra utilities and add-ons for Nengo
https://www.nengo.ai/nengo-extras
Other
5 stars 8 forks source link

Cannot be imported without tkinter #77

Closed jgosmann closed 6 years ago

jgosmann commented 6 years ago

The nengo-extras import fails if Python is not installed with tkinter. Can we fix this and have a release quickly? I'd like to use nengo-extras in my tutorial on Friday, but I am afraid that participants might run into this problem without any quick way to fix it due to a variety environments.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-170-cae318af19f6> in <module>()
----> 1 import nengo_extras

~/Library/Python/3.6/lib/python/site-packages/nengo_extras/__init__.py in <module>()
      5 from .convnet import Conv2d, Pool2d
      6 from .neurons import FastLIF, SoftLIFRate
----> 7 from . import (
      8     camera, data, dists, graphviz, gui, networks, neurons, probe, vision)
      9 

~/Library/Python/3.6/lib/python/site-packages/nengo_extras/data.py in <module>()
      9 import numpy as np
     10 
---> 11 from .compat import pickle_load_bytes, urlretrieve
     12 
     13 

~/Library/Python/3.6/lib/python/site-packages/nengo_extras/compat.py in <module>()
      9     from io import StringIO
     10     from urllib.request import urlretrieve
---> 11     import tkinter
     12 
     13 

/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py in <module>()
     34 import sys
     35 
---> 36 import _tkinter # If this fails your Python may not be configured for Tk
     37 TclError = _tkinter.TclError
     38 from tkinter.constants import *

ModuleNotFoundError: No module named '_tkinter'
jgosmann commented 6 years ago

Given that many things in nengo-extras are not as well tested across different environments, it might be best to reduce what we import by default? Because all I need is nengo_extras.learning_rules, but importing it is prevented by the nengo_extras default imports that fail.

tbekolay commented 6 years ago

Yeah, that makes sense, I'll remove most of what's in __init__.py and we can hopefully do a release tonight or tomorrow.

tbekolay commented 6 years ago

Done in #78.