How do I install Keras and Theano in Anaconda Python on Windows? - python-2.7

I am trying to work on neural networks in Python using the following Keras packages:
from keras.utils import np_utils
from keras.layers.core import Dense, Activation, Dropout
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.optimizers import SGD
But, I am getting the following error:
15 import theano
---> 16 from theano import gof
17 from theano.compat.python2x import partial
18 import theano.compile.mode
ImportError: cannot import name gof
Installing installed conda install keras. Later I tried to use pip install Theano, but it did not work. I Tried to install using pip install git, but I am getting this error: cannot find command git. So I installed Git and I set the environment variables.
So, is there any procedure to install these packages?

It is my solution for the same problem
Install TDM GCC x64.
Install Anaconda x64.
Open the Anaconda prompt
Run conda update conda
Run conda update --all
Run conda install mingw libpython
Install the latest version of Theano,
pip install git+git://github.com/Theano/Theano.git
Run pip install git+git://github.com/fchollet/keras.git

The trick is that you need to create an environment/workspace for Python. This solution should work for Python 2.7 but at the time of writing keras can run on python 3.5, especially if you have the latest anaconda installed (this took me awhile to figure out so I'll outline the steps I took to install KERAS in python 3.5):
Create environment/workspace for Python 3.5
C:\conda create --name neuralnets python=3.5
C:\activate neuralnets
Install everything (notice the neuralnets workspace in parenthesis on each line). Accept any dependencies each of those steps wants to install:
(neuralnets) C:\conda install theano
(neuralnets) C:\conda install mingw libpython
(neuralnets) C:\pip install tensorflow
(neuralnets) C:\pip install keras
Test it out:
(neuralnets) C:\python -c "from keras import backend; print(backend._BACKEND)"
Just remember, if you want to work in the workspace you always have to do:
C:\activate neuralnets
so you can launch Jupyter for example (assuming you also have Jupyter installed in this environment/workspace) as:
C:\activate neuralnets
(neuralnets) jupyter notebook
You can read more about managing and creating conda environments/workspaces
at the follwing URL: https://conda.io/docs/using/envs.html

In windows with anaconda, just go on conda prompt and use this command
conda install --channel https://conda.anaconda.org/conda-forge keras

I use macOS and used to have the same problem.
Running the following command in the terminal saved me:
conda install -c conda-forge keras tensorflow
Hope it helps.

In case you want to train CNN's with the theano backend like the Keras mnist_cnn.py example:
You better use theano bleeding edge version. Otherwise there may occur assertion errors.
Run Theano bleeding edge
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Run Keras (like 1.0.8 works fine)
pip install git+git://github.com/fchollet/keras.git

install by this command given below
conda install -c conda-forge keras
this is error "CondaError: Cannot link a source that does not exist" ive get in win 10.
for your error put this command in your command line.
conda update conda
this work for me .

In windows environment with Anconda. Go to anconda prompt from start. Then if you are behind proxy then .copndarc file needs to eb updated with the proxy details.
ssl_verify: false
channels:
- defaults
proxy_servers:
http: http://xx.xx.xx.xx:xxxx
https: https://xx.xx.xx.xx:xxxx
I had ssl_verify initially marked as 'True' then I was getting ssl error. So i turned it to false as above and then ran the below commands
conda update conda
conda update --all
conda install --channel https://conda.anaconda.org/conda-forge keras
conda install --channel https://conda.anaconda.org/conda-forge tensorflow
My python version is 3.6.7

Anaconda with Windows
Run anaconda prompt with administrator privilages
conda update conda
conda update --all
conda install mingw libpython
conda install theano
After conda commands it's required to accept process - Proceed ([y]/n)?

Related

Installing PyMC3 on Anaconda 3 / Win

This installation is a nightmare!!!
Using:
conda install -c conda-forge pymc3
Will not work.
I then tried to install theano first (and its dependencies), found out the hard way that it works with python=3.5, NOT 3.6.
# Install theano reqirements
conda install numpy scipy mkl-service libpython m2w64-toolchain
# Install theano
conda install theano pygpu
# You are using a different python version (3.5) from the base installation,
# you must point to the right kernel for Jupyter:
conda install ipykernel
python -m ipykernel install --user
# Install & test on jupyter, spyder
conda install jupyter spyder qt
# Install PyMC3
pip install pymc3
Everything imports, but then when I run the code the 'NUTS' thing won't initialize...
Not sure which process worked for me but this is the step I took
reset my whole laptop
re-download wsl2
install conda
go to this directory
path_to_your_python_env>/Lib/site-packages/theano/misc/windows.py
delete or comment out following
params['shell'] = True
Even though it works, the compiler is extremely still slows

pip install in google deep learning vm

I'm using one of the deep leaning images but am really only familiar with installing packages using conda which appears to not be used in the image. How do I pip install a package to my jupyter notebook kernel?
You can install python packages from Jupyter Kernel like this:
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
You can have a look at this document for more detailed information.

Install opencv python package in Anaconda

Can someone provide the steps and the necessary links of the dependencies to install external python package "opencv-python" for image processing?
I tried installing it in pycharm, but it was not able to import cv2(opencv) and was throwing version mismatch with numpy!
Please help!
The good thing with anaconda is that it should make your life easier without getting your hands too dirty. If you use only basic libs, only install packages with anaconda commands to be sure not to corrupt your python environment.
if you're on linux, use conda install -c conda-forge opencv
on windows, do the same with the "anaconda prompt" terminal.
If you still have some trouble with you numpy version, try conda update numpy
Create a virtual env. Following which run following instals
pip install numpy scipy matplotlib scikit-learn jupyter
pip install opencv-contrib-python
pip install dlib
You may verify the install via this script in Python environment-
import cv2
cv2.version
Remove all previous/current (if any) python installation
Install Anaconda and add anaconda to PATH(Envirnoment variables:: Adavanced system setting->Environment variables->under system variables go to variable PATHand click edit to add new envirnomental variables)
(During installation check box involve PATH)
Open anaconda prompt with admin access. Type and enter:-
conda update --all
conda install -c conda-forge opencv
conda install spyder=4.0.0 (spyder updation)
conda update python (for python updation)
To install this package with conda run one of the following:
conda install -c conda-forge opencv
conda install -c conda-forge/label/gcc7 opencv
conda install -c conda-forge/label/broken opencv
conda install -c conda-forge/label/cf201901 opencv

installing seaborn without sudo

I am trying to install seaborn without using sudo. I have already installed on my python 2.7 and windows 7 setting with the following cmd commands :
pip install pandas
pip install xlrd
pip install matplotlib
and they all were installed like charm.
`pip install seaborn` did not work
i have attached the error message.[last lines of emssage][1]
You may be interested in installing precompiled python wheel binaries for Windows.
That, or use something like Anaconda python.

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'