lmjohns3 / theanets

Neural network toolkit for Python
http://theanets.rtfd.org
MIT License
328 stars 74 forks source link

Using theanets with ipython notebook #90

Closed spudzee closed 8 years ago

spudzee commented 8 years ago

I'm trying to use theanets in ipython notebook. But when I do "import theanets" it returns this error: http://pastebin.com/w7FNUAFh

I understand that curses is used for terminal, for (I think) unix based systems. I'm using a Windows (7), and furthermore I'm using ipython notebook, with Anaconda.

It looks like curses is used in climate. So I tried going to all the places where climate referenced curses (there is 1, it looks like): log.py. So I tried removing the curses references in there, but I couldn't work out how to do it without removing (what appeared to be) important code. So I tried going a few steps back, and go to the place(s) where log.py is referenced. feedforward.py is what showed up on the error. I also had trouble finding a way to cut the ties with the graph import, from my reasoning, it looked like this was just used for visually displaying (graphing) the information contained in the neural network. But again I couldn't find a way to do it without ruining everything, and causing a million compiler errors.

So I need to either a) change the code so it imports curses correctly, or b) cut the ties with curses. Either solution works with me.

mtambos commented 8 years ago

I encountered the same error while trying to get theanets to work on Windows. It turns out there's no port of curses to this OS, so I had to hack a bit :) The attached patch surrounds the import with a try-except. I'm using this right now on Windows and from an IPython notebook.

On Fri, Jul 31, 2015 at 3:50 AM, spudzee notifications@github.com wrote:

I'm trying to use theanets in ipython notebook. But when I do "import theanets" it returns this error: http://pastebin.com/w7FNUAFh

I understand that curses is used for terminal, for (I think) unix based systems. I'm using a Windows (7), and furthermore I'm using ipython notebook, with Anaconda.

It looks like curses is used in climate. So I tried going to all the places where climate referenced curses (there is 1, it looks like): log.py. So I tried removing the curses references in there, but I couldn't work out how to do it without removing (what appeared to be) important code. So I tried going a few steps back, and go to the place(s) where log.py is referenced. feedforward.py is what showed up on the error. I also had trouble finding a way to cut the ties with the graph import, from my reasoning, it looked like this was just used for visually displaying (graphing) the information contained in the neural network. But again I couldn't find a way to do it without ruining everything, and causing a million compiler errors.

So I need to either a) change the code so it imports curses correctly, or b) cut the ties with curses. Either solution works with me.

— Reply to this email directly or view it on GitHub https://github.com/lmjohns3/theanets/issues/90.

lmjohns3 commented 8 years ago

I've released a new version of climate that should address this. Please run pip install -U climate and close this issue if it's fixed!

spudzee commented 8 years ago

it fixed the error I was getting, but now I'm getting this: http://pastebin.com/3TMS2edw when I import theanets. Should I open this in a separate issue?

I tried changing the import to "from theanets import activations" in base.py - same error. I don't really know why this is happening since I can clearly see the "activations.py" file in the theanets folder. Perhaps it's trying to import from the wrong directory? Then again, I don't really know why that would happen; just speculation.

lmjohns3 commented 8 years ago

Hm, bizarre! It might be helpful to run the following in a terminal:

python -v
>>> import theanets

This will print out a lot of information describing where the Python interpreter is trying to look when importing different modules. It could be useful in tracking down what's happening for this import.

spudzee commented 8 years ago

ok, I did what you said, and it produced this result: http://pastebin.com/LyFjmUW0 I have no idea what any of that means and therefore can't even begin to parse it.

lmjohns3 commented 8 years ago

Did you get the ImportError this time as well? It doesn't look like there's anything suspicious in the log that you posted.

Also, in looking back over the stack trace that you posted above, something weird is happening with your theanets imports. In the first stack frame, the error is coming from running line 4:

      D:\Users\spudzee\Anaconda3\lib\site-packages\theanets\__init__.py in <module>()
      2
      3 from .activations import Activation
----> 4 from .feedforward import Autoencoder, Regressor, Classifier
      5 from .graph import Network
      6 from .layers import Layer

But that means that the interpreter has finished running line 3, which is an import of the activations module. Something seems fishy there.

I looked around a little on stack overflow and found this:

http://stackoverflow.com/questions/28058511/pandas-import-error-with-anaconda-hashtable

It could be that Anaconda or pip have done something amiss. Maybe try removing theanets and reinstalling it? (Make sure you remove it completely first.)

spudzee commented 8 years ago

I actually didn't install theanets with pip, I downloaded the zip, and put theanets in the site-packages directly. I couldn't get pip to work. When I did "pip install theanets" it said,"can't open pip-script.py" but that's probably more of an Anaconda issue, and therefore not particularly relevant to this thread.

I removed the Theanets folder from site-packages, and then (just to make sure) re-downloaded the zip, and installed it (manually) again. "import theanets" doesn't produce any compiling errors now.

Thanks!

I'm gonna close this issue now.