|
Keras的安装
1-介绍2-创建虚拟环境3-tensorflow与keras安装4-错误记录-等待解决
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
复制代码 结果图如下:
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中输入以下指令:出现如下图所示既安装成功。
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>ifnot 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>ifnot exist ""(set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional" )
- C:\Users\WW>ifnot exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" )
- C:\Users\WW>ifnot exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community" (set "VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" )
- C:\Users\WW>ifnot 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 )
- 系统找不到指定的文件。
- 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\
- 系统找不到指定的路径。
- C:\Users\WW>CALL "VC\Auxiliary\Build\vcvars64.bat"-vcvars_ver=14.16
- 系统找不到指定的路径。
- 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
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|