I am too lazy to upgrade the system, so I still use 64-bit win7.
1. Install Anaconda (strongly recommended)
Anaconda has integrated a large number of third-party packages, and there is no need to manually install them one by one, which will save a lot of time and effort, so it is strongly recommended to download an Anaconda installation package. I use Anaconda3-2020.07-Windows-x86_64, about 467M. Visiting foreign official websites is not smooth, and can be replaced by many domestic mirror websites, which are basically available for download.
2. Install support packages mingw and libpython
If you have access to foreign official websites, you can open Anaconda in the start menu and click to run Anaconda Powershell Prompt, and enter
conda install mingw libpython
If the network speed is excellent, the entire installation process is smooth, and the installation can basically be completed quickly.
If you cannot access foreign websites, you need to add the mirror image of Tsinghua University (HKUST, Douban, etc.), and enter in Anaconda Powershell Prompt:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
If there is an HTTP error in the above process, it may be due to the https problem, try to change it to:
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
Then run:
conda install mingw libpython
After the installation is successful, you can see the version of mingw and libpython in the base (root) in the Environment of Anaconda Navigator ""
3. Add MinGW environment variables
Right-click on My Computer, select Properties, and then click Advanced System Settings
Find the environment variable in the advanced, find the path variable. If it is a newly installed system and there is no path variable, create a new path and add it to it.
Add "; C:\ProgramData \Anaconda3\MinGW\lib; C:\ProgramData\ Anaconda3\MinGW\x86_64-mingw32\lib;" at the end
Note: Only enter the characters in the quotation marks, pay attention to bring the English semicolon as the separator; please change the above red characters according to the specific installation directory.
4. Install theano and keras
Enter in Anaconda Powershell Prompt:
pip install theano hard
Wait patiently for the installation process to end.
5. Change the default background of keras
The backend of keras defaults to tensorflow, you need to manually change theano;
Find the keras.json configuration file in C:\Users\Administrator\.keras\, open it with Notepad, change the tensorflow inside to theano, save and exit.
6. Test
Enter in Anaconda Powershell Prompt:
python
After entering Python, enter the following command:
import theano
It may take a while before you can continue to enter the command. As long as there is no prompt message, it is a good phenomenon. Then enter:
print(theano.config.blas.ldflags)
The normal output of the print function means that theano is installed normally and can be used. Next verify Keras. enter:
hard import
Using Theano backend will appear. If there is no error message, it means that keras is installed successfully!