windows 10 下 pip,conda 换国内源,安装Tensorflow,Keras
修改pip源 参考
官方文档
windows 全部用户需要在%APPDATA%\pip\pip.ini
,当前用户在%HOME%\pip\pip.ini
[global]index-url=http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com复制代码
安装Tensorflow
参考
# 切换到 python3.5 参考 详见另外一篇博文 https://anjia.ml/2017/07/02/anaconda-install-and-configurating-jupyter/#切换python版本#打开Anaconda Prompt(python35) C:\Users\xx> activate python35#因为电脑无独显,所以安装`CPU-only`版本(python35) C:\Users\xx> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl (python35) C:\Users\xx>python复制代码
>>> import tensorflow as tf>>> hello = tf.constant('Hello, TensorFlow')>>> sess = tf.Session()2017-07-03 16:44:16.082952: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.085175: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.085590: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.085952: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.086312: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.086634: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.087014: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.2017-07-03 16:44:16.087363: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.>>> print(sess.run(hello))b'Hello, TensorFlow'复制代码
如果要去掉4-12
的警告信息,需要自己编译。详见
安装Keras
参考 官方文档 中文文档
(python35) C:\Users\xx>pip install keras -U --pre复制代码
但是我安装一直报错,
Running setup.py bdist_wheel for scipy ... error Complete output from command {Anaconda3_home}\envs\python35\python.exe -u -c "import setuptools, tokenize;__file__='{AppData}\\Local\\Temp\\pip-build-mgdjtt1d\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d {AppData}\Local\Temp\tmpb_od_dlvpip-wheel- --python-tag cp35: lapack_opt_info: lapack_mkl_info: libraries mkl_rt not found in ['{Anaconda3_home}\\envs\\python35\\lib', 'C:\\', '{Anaconda3_home}\\envs\\python35\\libs'] NOT AVAILABLE## ...Command "{Anaconda3_home}\envs\python35\python.exe -u -c "import setuptools, tokenize;__file__='{AppData}\\Local\\Temp\\pip-build-mgdjtt1d\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record {AppData}\Local\Temp\pip-htcraop7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in {AppData}\Local\Temp\pip-build-mgdjtt1d\scipy\复制代码
网上有建议通过 pip install git+git://github.com/Theano/Theano.git
从github直接下最新代码安装的,但是也是安装失败
我成功的方式
(python35) C:\Users\xx>conda install mingw libpython theano -y(python35) C:\Users\xx>pip install keras复制代码
天朝网络不稳定,挺慢的,可以参考 另外一篇博文切换清华源
(python35) C:\Users\xx>pythonPython 3.5.3 |Continuum Analytics, Inc.| (default, May 15 2017, 10:43:23) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import kerasUsing TensorFlow backend.复制代码
安装成功,默认后端是TensorFlow
博客
掘金 简书