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

No module named nonlinearities #624

Closed
m-decoster opened this issue Feb 24, 2016 · 14 comments

Comments

@m-decoster
Copy link

commented Feb 24, 2016

Operating System: OS X El Capitan 10.11.1

I have installed Theano and Lasagne as per the instructions in the README.md file, but I keep getting the same error when trying to run the example also in that file:

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    import lasagne
  File "/private/tmp/lasagne.py", line 10, in <module>
    from lasagne.nonlinearities import leaky_rectify, softmax
ImportError: No module named nonlinearities

I have tried reinstalling Lasagne and Theano, but I keep getting this error.

@f0k

This comment has been minimized.

Copy link
Member

commented Feb 24, 2016

As you see, import lasagne tries to import the module from /private/tmp/lasagne.py, which is not actually the module you have installed. You will need to move /private/tmp/lasagne.py outside of your PYTHONPATH so it doesn't shadow the actual Lasagne module.

@f0k f0k closed this Feb 24, 2016

@ghost

This comment has been minimized.

Copy link

commented Mar 2, 2016

Operating System: Ubuntu 14.04

I have a similar error:

Traceback (most recent call last):
File "mnist.py", line 33, in <module>
import lasagne
File "/home/dbankman/.local/lib/python2.7/site-packages/lasagne/__init__.py", line 22, in <module>
from . import nonlinearities
ImportError: cannot import name nonlinearities

This error only appears when I set device=gpu.

I've installed the "bleeding edge versions" of Theano and Lasagne:
pip install --upgrade https://github.com/Theano/Theano/archive/master.zip --user
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip --user

@ghost

This comment has been minimized.

Copy link

commented Mar 3, 2016

I found that running
theano-cache clear
fixes the problem. Does anyone know exactly what that does?

@f0k

This comment has been minimized.

Copy link
Member

commented Mar 3, 2016

Does anyone know exactly what that does?

It deletes your current ~/.theano/compiledir-... which caches compiled modules generated by Theano when compiling a function or when activating GPU support. When you update your CUDA version or graphics driver, it may happen that the GPU support module cannot be imported any longer as it links to earlier versions of system libraries, thus import theano fails, thus from . import nonlinearities fails, thus import lasagne fails. Forcing a recompile by deleting the theano cache is the easiest solution then.

@Jonbean

This comment has been minimized.

Copy link

commented May 25, 2016

Operating System: OS X El Capitan 10.11.5
@dbankman I have the similar problem and theano-cache clear doesn't work either.

Here's my installation result:

pip install https://github.com/Lasagne/Lasagne/archive/master.zip Collecting https://github.com/Lasagne/Lasagne/archive/master.zip Downloading https://github.com/Lasagne/Lasagne/archive/master.zip (203kB) 100% |████████████████████████████████| 204kB 1.3MB/s Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Lasagne==0.2.dev1) Installing collected packages: Lasagne Running setup.py install for Lasagne ... done Successfully installed Lasagne-0.2.dev1

Here's the error:

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-950fc8a00ce6> in <module>()
----> 1 import lasagne

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lasagne/__init__.py in <module>()
22
23
---> 24 from . import nonlinearities
25 from . import init
26 from . import layers

ImportError: cannot import name nonlinearities

@benanne

This comment has been minimized.

Copy link
Member

commented May 26, 2016

What happens when you run import theano?

If possible, could you repost this question on our mailing list, so we can continue the discussion there? https://groups.google.com/forum/#!forum/lasagne-users
Our issue queue is not intended to be used for support. Thanks for your understanding and cooperation!

@silverlining21

This comment has been minimized.

Copy link

commented Dec 7, 2016

@dankolbman
theano-cache clear
I found it works for me only once, I need to re-run this cmd for each single time. that's not convenient at all.

@maltanar

This comment has been minimized.

Copy link

commented Feb 11, 2017

Not sure if it's a viable workaround, but changing the order of module imports solved this problem for me:

import lasagne
import theano

@Eugenie-uv

This comment has been minimized.

Copy link

commented Apr 10, 2017

File "C:\Anaconda\lib\site-packages\lasagne_init_.py", line 17, in
from . import nonlinearities

ImportError: cannot import name nonlinearities

@f0k

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

@Euniceu: What happens when you run python -c "import theano"?

@Eugenie-uv

This comment has been minimized.

Copy link

commented Apr 10, 2017

@f0k nothing happend. I think I intalled theano corrected.

@f0k

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

Yes, if nothing happens, theano was imported successfully. Does your C:\Anaconda\lib\site-packages\lasagne look complete, i.e., does it contain a nonlinearities.py? When you run python -c "import lasagne", do you get the stack trace posted before? What happens if you run python -c "import lasagne.nonlinearities"?

@sashavor

This comment has been minimized.

Copy link

commented Apr 9, 2018

Has there been any progress in finding a solution to this? I have the same error...

@f0k

This comment has been minimized.

Copy link
Member

commented Apr 25, 2018

@sashavor: There are different errors resulting in that message, and therefore different solutions. What's your setup? How did you install Lasagne? What directory are you in when trying to import it, and what path has Lasagne been installed to? Is there any other lasagne.py on your python path that shadows the installed module?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.