Anaconda + spyder + keras download and settings under win10 (Chinese, environment variable settings, DPI scaling, etc.)

1. Download and installation of anaconda

As a research dog who is used to matlab, when he first chose the python compiler, he did not hesitate to choose spyder, so he installed an integrated environment (true fragrance) under the recommendation of the big brother. anaconda is a free and open source software, you can directly select the corresponding system to download on the official website. I directly used the original installation package. There are two points to explain:
1. If the hard disk is enough, try to use the default installation location . It happened before because of the installation to other disks, some errors occurred (specifically forgot what, but reinstalled to the C drive to solve it).
2. Try not to bring Chinese in the path name, you may get an error.
3. Try not to add environment variables during installation , which may pollute your environment variables. That is, do not check the first one. Then manually add environment variables (how to add them below)
1

1. Setting of environment variables

Many times, we need to directly enter the python editor in cmd. If you do not set the environment variables, cmd will not be able to find your python.

  • First open the environment variable setting page.
    Insert picture description here
    Insert picture description here
    Insert picture description here
  • Open the installation folder of anaconda and add the paths of the following three folders to the environment variables, which is basically enough.
    Insert picture description here
  • Use cmd to open python, if it can be opened normally, you are done.Insert picture description here

Second, the setting of spyder

1. Chinese localization of spyder

Spyder's installation and localization (typing is too tired, here to reprint the blog of other big brothers, download the finished file on git and install it according to the README of others).

Another thing I learned is: right-click on Windows 10 and add "open command window here" . I used win7 before, and I don't know what powershell is. I still used cmd to install the finished package above. Hereby record it.

  1. Create a new txt file and name it OpenCmdHere.txt.
  2. Enter the following code in the file.
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere]
@="在此处打开命令窗口"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere\command]
@="cmd.exe /s /k pushd "%V""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="在此处打开命令窗口"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere]
@="在此处打开命令窗口"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere]
@="在此处打开命令窗口"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere\command]
@="cmd.exe /s /k pushd \"%V\""

  • Save as, change the file extension to reg, and set the encoding to ANSI.
  • Double-click the OpenCmdHere.reg file to run, and the pop-up prompt point is confirmed. For a folder, hold down shift and click the right mouse button.
    Insert picture description here

2. Set the spyder's layout, DPI zoom and pop-up window display pictures

  • After setting the Chinese interface, in order to facilitate use, we will also consider adjusting the layout of spyder to facilitate writing programs. You can set the pane and layout of spyder. After checking the required panes, it is very convenient to adjust the page layout like adjusting matlab.
    Insert picture description here
  • Due to the DPI scaling (150%) of the win10 system, the spyder's interface may be unclear, and setting the intelligent scaling will be ok.
    Insert picture description here
  • IPython supports two forms of drawing
    1. Terminal output image
    2. New window output image
    Method 1 can be very convenient to save the output record (such as the conversion of `IPython terminal output into Html file)
    Method 2 can interactively zoom in and drag Pictures, and can save pictures in different formats
    For spyder, you can change the default options in the settings.
    Tools> Preferences> As shown below
    Insert picture description here
    : Inline is the terminal output, and automatic is the new window output.

Three, keras + TensorFlow environment settings

Since anaconda does not install keras by default, you must install keras manually for those who are engaged in machine learning. Three points to remember during installation:

  • Install TensorFlow first, then install keras . Because TensorFlow is the backend.
  • Pay attention to the version of the installation package . Because the versions of spyder and python are different, choose the version that suits you. And according to the big guys, TensorFlow2.0 is not very easy to use.
  • Some small partners may experience installation timeouts. This is due to the Internet speed of the pit father. You can choose a domestic mirror source to fly quickly.

Open the anaconda prompt in the start menu bar and enter the following command:

python -V #查询python版本号
anaconda search -t conda tensorflow  #查询可安装包的版本

Many versions will pop up, choose your own. Mine is win10, python3.7.3, TensorFlow1.15.2, keras2.3.1

conda install tensorflow=1.15.2 #安装tensorflow

If the network speed is particularly slow, you can use the domestic pip mirror source:

pip install tensorflow==1.15.2 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

At the same time, install numpy, pandas, scipy and matplotlib together according to the above scheme. (Speed ​​can reach 2 ~ 3M)
Note that the version number specified by conda is =, and the version number specified by pip is == . The similarities and differences between conda and pip can be seen here . If they are not professional programmers, they can manage python packages.
Finally install keras.

pip install keras==2.3.1 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

Enter, the following appears, and you are done.

python
import keras

Insert picture description here
In addition, when it is installed by mistake or half of the network is installed slowly, there will be some cached package files in conda, which may cause errors. Conda clean can be easily done! Step 1: Use conda clean -p to delete some useless packages. This command will check which packages are not hard dependent in the package cache and delete them. The second step: through conda clean -t can delete the tar package saved by conda.

Quote conda common commands

conda clean -p      #删除没有用的包
conda clean -t      #删除tar包
conda clean -y -all #删除所有的安装包及cache
Published 2 original articles · praised 7 · visits 99

Guess you like

Origin blog.csdn.net/weixin_44019644/article/details/105396452
Recommended