【Keras环境的安装】

【自取】最近整理的,有需要可以领取学习:

Keras的安装

1-介绍

1,keras需要在TensorFlow之上才能运行,所以要先安装tensorflow.

2,Tensorflow只能在3.7以前的python版本中运行,所以需要先创建一个基于python 3.6的虚拟环境.

2-创建虚拟环境

打开anaconda prompt,输入命令:

#创建虚拟环境名
conda create -n tensorflow_py36 python=3.6
#查看已创建环境
conda info --envs
#激活到创建的环境中去
conda activate tensorflow_py36

结果图如下:

【Keras环境的安装】

3-tensorflow与keras安装

keras搭建在tensorflow基础上,在安装keras安装之前需要安装tensorflow、numpy、matplotlib、scipy。

conda install numpy
conda install matplotlib
conda install scipy
conda install tensorflow
conda install keras

然后验证是否安装成功,在anaconda prompt中输入以下指令:

python
import keras

安装成功,如下图所示。

[En]

The installation is successful, as shown in the figure below.

【Keras环境的安装】

4-错误记录-等待解决

在安装的过程中出现了以下情况,等待后续的解决。但是我在pycharm中可以使用keras。

C:\Users\WW>python E:\anaconda\anaconda\envs\tensorflow_py36\etc\keras\load_config.py  1>temp.txt
C:\Users\WW>set /p KERAS_BACKEND= 0<temp.txt
C:\Users\WW>del temp.txt
C:\Users\WW>python -c "import keras"  1>nul 2>&1
C:\Users\WW>if errorlevel 1 (
ver  1>nul
 set "KERAS_BACKEND=theano"
 python -c "import keras"  1>nul 2>&1
)
C:\Users\WW>SET DISTUTILS_USE_SDK=1
C:\Users\WW>SET MSSdk=1
C:\Users\WW>SET "VS_VERSION=15.0"
C:\Users\WW>SET "VS_MAJOR=15"
C:\Users\WW>SET "VS_YEAR=2017"
C:\Users\WW>set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"
C:\Users\WW>set "MSYS2_ENV_CONV_EXCL=CL"
C:\Users\WW>set "PY_VCRUNTIME_REDIST=\bin\vcruntime140.dll"
C:\Users\WW>set "CXX=cl.exe"
C:\Users\WW>set "CC=cl.exe"
C:\Users\WW>set "VSINSTALLDIR="
C:\Users\WW>set "NEWER_VS_WITH_OLDER_VC=0"
C:\Users\WW>for /F "usebackq tokens=*" %i in (vswhere.exe -nologo -products * -version [15.0,16.0) -property installationPath) do (set "VSINSTALLDIR=%i\" )
C:\Users\WW>if not exist "" (for /F "usebackq tokens=*" %i in (vswhere.exe -nologo -products * -requires Microsoft.VisualStudio.Component.VC.v141.x86.x64 -property installationPath) do (
set "VSINSTALLDIR=%i\"
 set "NEWER_VS_WITH_OLDER_VC=1"
) )
C:\Users\WW>if not exist "" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" )
C:\Users\WW>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" )
C:\Users\WW>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" )
C:\Users\WW>if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\" )
C:\Users\WW>IF NOT "" == "" (
set "INCLUDE=;"
 set "LIB=;"
 set "CMAKE_PREFIX_PATH=;"
)
C:\Users\WW>call :GetWin10SdkDir
C:\Users\WW>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1
C:\Users\WW>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1
C:\Users\WW>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1
C:\Users\WW>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1
C:\Users\WW>if errorlevel 1 exit /B 1
C:\Users\WW>exit /B 0
C:\Users\WW>for /F %i in ('dir /ON /B "\include\10.*"') DO (SET WindowsSDKVer=%~i )
系统找不到指定的文件。<details><summary>*<font color='gray'>[En]</font>*</summary>*<font color='gray'>The system cannot find the specified file.</font>*</details>
C:\Users\WW>if errorlevel 1 (echo "Didn't find any windows 10 SDK. I'm not sure if things will work, but let's try..." )  else (echo Windows SDK version found as: "" )
Windows SDK version found as: ""
C:\Users\WW>IF "win-64" == "win-64" (
set "BITS=64"
 set "CMAKE_PLAT=x64"
)  ELSE (
set "BITS=32"
 set "CMAKE_PLAT=Win32"
)
C:\Users\WW>IF 2017 GEQ 2019 (
set "CMAKE_GEN=Visual Studio 15 2017"
 set "USE_NEW_CMAKE_GEN_SYNTAX=1"
)  ELSE (
IF "win-64" == "win-64" (set "CMAKE_GEN=Visual Studio 15 2017 Win64" )  else (set "CMAKE_GEN=Visual Studio 15 2017" )
 set "USE_NEW_CMAKE_GEN_SYNTAX=0"
)
C:\Users\WW>echo "NEWER_VS_WITH_OLDER_VC=0"
"NEWER_VS_WITH_OLDER_VC=0"
C:\Users\WW>IF "0" == "1" (
set "CMAKE_GEN=Visual Studio 16 2019"
 set "USE_NEW_CMAKE_GEN_SYNTAX=1"
)
C:\Users\WW>IF "" == "" SET "CMAKE_GENERATOR=Visual Studio 15 2017 Win64"
C:\Users\WW>IF "0" == "1" (
IF "" == "" SET "CMAKE_GENERATOR_PLATFORM=x64"
 IF "" == "" SET "CMAKE_GENERATOR_TOOLSET=v141"
)
C:\Users\WW>pushd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\
系统找不到指定的路径。<details><summary>*<font color='gray'>[En]</font>*</summary>*<font color='gray'>The system cannot find the specified path.</font>*</details>
C:\Users\WW>CALL "VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16
系统找不到指定的路径。<details><summary>*<font color='gray'>[En]</font>*</summary>*<font color='gray'>The system cannot find the specified path.</font>*</details>
C:\Users\WW>popd
C:\Users\WW>call :GetWin10SdkDirHelper HKLM\SOFTWARE\Wow6432Node  1>nul 2>&1
C:\Users\WW>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE\Wow6432Node  1>nul 2>&1
C:\Users\WW>if errorlevel 1 call :GetWin10SdkDirHelper HKLM\SOFTWARE  1>nul 2>&1
C:\Users\WW>if errorlevel 1 call :GetWin10SdkDirHelper HKCU\SOFTWARE  1>nul 2>&1
C:\Users\WW>if errorlevel 1 exit /B 1
C:\Users\WW>exit /B 0

Original: https://blog.csdn.net/Alexa_/article/details/123801758
Author: Alexa2077
Title: 【Keras环境的安装】

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/7716/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

发表回复

登录后才能评论
免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部