python lasagne ImportError cannot import BatchNormLayer - python-2.7

When I try to play with the code here, I met a very strange error.
Every other modules can be imported properly, except for one.
Specifically, the error is:
ImportError: cannot import name BatchNormLayer
from the file here. And the lasagne_extensions.layers is as following:
from .density_layers import *
from lasagne.layers import *
from parmesan.layers import *
So, I believe the problem should be that I didn't install lasagne or parmesan properly.
I have tried to upgrade the relevant modules including numpy, scipy, theano and lasagne to newest version with pip install --upgrade respectively. There is no pip install support for parmesan, so I downloaded it and installed it again.
However, the error remains.
Can anyone give me some advice about what I should look into?

The solution is to install the cutting-edge version, and pip install --upgrade does not do that.
But the problem can be solved by:
pip install --upgrade https://github.com/Theano/Theano/archive/master.zip
pip install --upgrade https://github.com/Lasagne/Lasagne/archive/master.zip
Details are here.

Related

numpy is not installing in windows 7 soon after get-pip.py

This is the error please help me what to do
i have downloaded all the dependencies but numpy is showing errors
you're using pip3 - that's for Python3.
Try pip install numpy

Error while running PIP command "no module packaging exists"

I have tried many approaches in resolving this issue but still cannot resolve it can someone please help me.
when I try to run the pip to install any new package it is ending in error with the message no module named packaging.version. This is happening in the __init__.py file where there are import command import packaging.version.
I tried to install the packaging package by using the command pip install packaging even that ended in failure with the same error.
Then I tried to install this package using the apt-get command
sudo apt-get install python-packaging but it ended saying could not find the package.
Finally I tried to update the setuptools package to version 33.1.1 as a part of the previous solutions approaches, but can't do it with pip(same issue as above) so I used the apt-get command
sudo apt-get install setuptools=33.1.1 but it is saying no package with this version found error.
I am out of ideas can someone please help. Appreciate your help.
I believe that your version of pip is obsolete. Try running pip install --upgrade pip.
If you cant do it (still the same error), I'd suggest to reinstall pip.
You can do it with get-pip.py file. Here you can find a quick guide: Installing pip setuptools and wheel.
You may also be able to reinstall it with python -m pip install -U pip.

pip is error,TypeError: __call__() takes exactly 2 arguments (1 given)

system
centos 7.2
Python 2.7.5
install
I install webhook
pip install webhook
### but hava error,then
yum install python-devel -y
## go on,pip doesn't workding
pip
error
Enter the command contain pip.Then
[root#location src]# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
So,what should I do?!
I had the same problem on a fresh virtualenv and apparently this is a conflict between the version requirements for packaging, pip and pyparsing with the new setuptools. What worked for me was to pin down the old one.
pip install setuptools==33.1.1
Update:
As another answer pointed out, pip has already fixed the bug, so you should try upgrading it instead of using the workaround above.
python -m pip install --upgrade --force pip
UPDATE:
Please see the solution lower in this thread by Pedro Werneck instead of this one. It's the correct way to solve the problem.
Preface: I do not recommend this!
This seems to work, but I have no idea what the consequences could be. This is cargo cult programming at its best! I'm only adding it here in case it can help someone in a bind.
I made changes to the file requirements.py where the error occurred. For #hysg, that would be this file:
/usr/lib/python2.7/site-packages/packaging/requirements.py
On me on OS X, it's here:
/Library/Python/2.7/site-packages/packaging/requirements.py
I modified the the offending line by removing the parentheses for the call to MARKER_EXPR, as demonstrated below:
#MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
And that worked.
Again, please be careful! I don't know what I'm doing and this could potentially cause more harm than good.
this is work well:
python -m pip install --upgrade --force pip
pip install setuptools==33.1.1
This is what worked for me:
pip install setuptools==33.1.1
It downgraded setuptools from 35.0.1 to 33.1.1 and pyparsing 1.5.7 installed!
Use the following command to upgrade pip, which has the bug fixed:
python -m pip install --upgrade --force pip
It worked for me (centos 7, python 2.7).
For more details: GitHub
I applied the fix
pip install setuptools==33.1.1
and it solved the problem for OSX 10.10.5 (Yosemite)
I ran into the same problem on a new virtualenv trying to install. I'm running python 2.7.11 and found the two commands belows solve the versioning problem with setuptools:
This forces a pip upgrade, which has a fix for the bug, but doesn't reinstall setup tools, so I was still running on setuptools version 35.0.1
python -m pip install --upgrade --force pip
This sets setuptools to an older version.
pip install setuptools==33.1.1
After this, I successfully installed my requirements.
None of the other uninstall/reinstall/force answers worked for me, but on OS X 10.10.5 with the system Python 2.7.10, I was able to do:
pip uninstall packaging pip
easy_install pip # this installed pip 1.4.1
pip install --upgrade pip # and this upgraded to the current pip
and I was then able to import pkg_resources without a problem.
Should really learn to stop messing with the system Python…
Actually, I had a problem that OS/system which means root, not sudo, has been the owner of the pip2 package. But after I had executed this command:
sudo apt-get remove python-pip
it worked like a charm.
Noting, of course that I have a debian distribution.
And then I used what Pedro suggested:
sudo pip install setuptools==33.1.1
It worked for me too (centos 7, python 2.7).
python -m pip install --upgrade --force pip
pip install setuptools==33.1.1

No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

Have found a similar issue, however haven't found proper solution.
Here's a code:
import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,2,5])
plt.show()
Run, got the message:
ImportError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
I run Linux Mint 18 with preinstalled python-2.7 and python-3.5 (I use python3), before that I was installing modules with a simple sudo apt-get install method and that worked great.
Before running this the code above, I've installed matplotlib in a usual way sudo apt-get install python-matplotlib. As it haven't worked out, started to look for solution.
Python location
which python3 /usr/bin/python3
Current Matplotlib installed
sudo find /usr | grep matplotlib /usr/lib/python3/dist-packages/matplotlib
My tries:
1) I've removed matplotlib with autoremove, and tried to make it sudo apt-get install python3-matplotlib instead. Didn't worked out.
2) Used: pip3 install matplotlib or sudo pip3 install matplotlib. Received errors like:
command python setup.py egg_info failed with error code 1 in /tmp/pip-build- ....
3) Then I found another solution:
sudo apt-get install virtualenv
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install matplotlib
Same outcome.
Haven't tried to use import sys sys.path.append('/usr/lib/pymodules/python2.7/')(proposed in link above), but as I am not sure what exactly this command does (quite a newbie to python and programming itself) - haven't risked.
If you are using pycharm and have matplotlib.py in your current working directory than you get this error. Just delete or rename the matplotlib.py file and it will work.
don't name any file as matplotlib.py within your working directory
In your working directory, check if there is any file matplotlib.py
Delete that file and import matplotib again. That should work.
simply install:
python -m pip install -U pip
python -m pip install -U matplotlib
I had the same problem reasons in my case were
python 3.8.2 with matplotlib that I downloaded was for 3.7. Make sure they are the same.
python 64 bits version with matplotlib 32bits. Make sure they are the same
Use python -m pip install package_which_you_need to install packages for Windows
Make sure to add to PATH the environment variables I forgot to do in my case
pip version was old use
Use python -m pip install --upgrade pip to upgrade pip to the latest for Windows
I saved the file name as matplotlib.py. Try to avoid that
Finally I typed matplotlib.pyplot as matplotlib.plyplot remember to check for typos first. The error message looks similar even though I corrected all the steps above.
ModuleNotFoundError: No module named 'matplotlib.pyplot'
ModuleNotFoundError: No module named 'matplotlib.plyplot'

ImportError: cannot import name corpora with Gensim

I have installed Anacoda Python v2.7 and Gensim v 0.13.0
I am using Spyder as IDE
I have the following simple code:
from gensim import corpora
I got the following error:
from gensim import corpora
File "gensim.py", line 7, in <module>
ImportError: cannot import name corpora
I reinstalled:
- Gensim
- Scipy
- Numpy
but still have the same issue.
I had the same problem, when I named my own script "gensim.py". It was trying to load the modules from itself when importing from gensym.
So, avoid using "gensim.py" as a name of your script.
You might want to refer to this issue. Apparently, Anaconda behaves weirdly: bundling a different version of Numpy at runtime or something. I recommend using pip to install Gensim. Or easy_install Here's a link to help you install it properly.
My issue got resolved by uninstalling then reinstalling gensim using pip
then upgrading it
pip uninstall gensim
pip install gensim
pip install --upgrade gensim