zoukankan      html  css  js  c++  java
  • Linux笔记 #07# 搭建机器学习环境

    环境: Debian 8.8 64位, 同样适用 win10 

    基本步骤:

    1. 安装 Python
    2. 安装必要的库
    3. 测试

    一、安装 Python

    延续之前的 搭建 Python 环境 选取折中版本 Python 3.4

    sudo apt-get install python3

    这个时候会遇到一个问题:同时装了Python3和Python2,怎么用pip?默认安装的 pip 对应的是 python 2.7

    选用最 简单直接的方案:

    apt-get purge -y python3-pip
    apt-get install python3-pip

    检查有没有安装好:

    root@xkfx:/opt/python# python3 -m pip -V
    pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

    更新到最新版本:

    python3 -m pip install --upgrade pip  

    用 pip 安装模块到对应 Python 版本的方法(指明 Python 版本):

    python3 -m pip install 模块名

    PS. -m 大概是 module模块的意思

    二、安装必要的库

    ipython:

    root@xkfx:~# python3 -m pip install ipython
    
    root@xkfx:/opt/python# ipython
    Python 3.4.2 (default, Oct 8 2014, 10:45:20) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: exit

    matplotlib:

    root@xkfx:~# python3 -m pip install matplotlib
    
    root@xkfx:~# python3
    Python 3.4.2 (default, Oct 8 2014, 10:45:20) 
    [GCC 4.9.1] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import xxxxxx
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ImportError: No module named 'xxxxxx'
    >>> import matplotlib

    numpy:

    root@xkfx:~# python3 -m pip install numpy
    Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
    Requirement already satisfied: numpy in /usr/local/lib/python3.4/dist-packages (1.14.2)
    root@xkfx:~# python3
    Python 3.4.2 (default, Oct 8 2014, 10:45:20) 
    [GCC 4.9.1] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy

    sklearn:

    root@xkfx:~# python3 -m pip install scipy
    
    root@xkfx:~# python3 -m pip install sklearn
    
    root@xkfx:~# python3
    Python 3.4.2 (default, Oct 8 2014, 10:45:20) 
    [GCC 4.9.1] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sklearn

    tensorflow:

    root@xkfx:~# python3 -m pip install tensorflow
    
    root@xkfx:~# python3
    Python 3.4.2 (default, Oct 8 2014, 10:45:20) 
    [GCC 4.9.1] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    >>> print(tf.__version__)
    1.7.0

    pandas:

    python3 -m pip install pandas 
    
     Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-kfazvlty http://mirrors.aliyun.com/pypi/packages/1b/d2/22cde5ea9af055f81814f9f2545f5ed8a053eb749c08d186b369959189a8/wheel-0.31.0-py2.py3-none-any.whl#md5=240d714477a715bcd90e94cb2c44f28c http://mirrors.aliyun.com/pypi/packages/20/d7/04a0b689d3035143e2ff288f4b9ee4bf6ed80585cc121c90bfd85a1a8c2e/setuptools-39.0.1-py2.py3-none-any.whl#md5=ca299c7acd13a72e1171a3697f2b99bc http://mirrors.aliyun.com/pypi/packages/70/25/1e1521e6ce2cf78ff4a8b06fbc2cd513ce004ec337000eddfe016fdf3fc6/Cython-0.28.2-cp34-cp34m-manylinux1_x86_64.whl#md5=e277ba5fdbbaab6e3434bdcf58e41d6a http://mirrors.aliyun.com/pypi/packages/fc/1b/a1717502572587c724858862fd9b98a66105f3a3443225bda9a1bd16ee14/numpy-1.9.3-cp34-cp34m-manylinux1_x86_64.whl#md5=e1130c8f540a759d79ba5e8960f6915a http://mirrors.aliyun.com/pypi/packages/02/64/c6c1c24ff4dbcd789fcfdb782e343ac23c074f6b8b03e818ff60eb0f937f/numpy-1.12.1-cp34-cp34m-manylinux1_x86_64.whl#md5=6288d4e9cfea859e03dc82879539d029 http://mirrors.aliyun.com/pypi/packages/1b/ee/f65826b2880f67652c21326565b4c166c7cdb1019f84b82af65e625475cd/numpy-1.13.1-cp34-cp34m-manylinux1_x86_64.whl#md5=c51520d0d3836c91cba18d1fa8cf299c" failed with error code 1 in None

    由于在 debian 下无论如何都没有成功安装 pandas 

    我最后决定在 windows  上搭建环境。。。

    三、测试

     把下面这段代码运行一下,没有报错基本就 ok 了。 

    import math
    
    from IPython import display
    from matplotlib import cm
    from matplotlib import gridspec
    from matplotlib import pyplot as plt
    import numpy as np
    import pandas as pd
    from sklearn import metrics
    import tensorflow as tf
    from tensorflow.python.data import Dataset
    
    tf.logging.set_verbosity(tf.logging.ERROR)
    pd.options.display.max_rows = 10
    pd.options.display.float_format = '{:.1f}'.format
  • 相关阅读:
    [转]我们应该做什么样的研究
    [转]面向服务架构(SOA)和企业服务总线(ESB)
    [转]程序员应知——团队精神
    vs2010 调试快捷键
    asp.net 获取ip的6种方法
    解决了防止用户重复登陆和session超时
    IE 10 也能随网站应变,图标决定一切!
    Sony VAIO Duo 11 游戏性能测试
    翻出Windows 8 当中的游戏管理器
    Office 2013预览版已到期,需要付费才可正常使用
  • 原文地址:https://www.cnblogs.com/xkxf/p/8933730.html
Copyright © 2011-2022 走看看