美文网首页程序员
linux-Anaconda+conda创建python-ten

linux-Anaconda+conda创建python-ten

作者: 水球喵 | 来源:发表于2018-05-03 15:25 被阅读0次

    Anaconda 安装包可以到清华 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载可选择之前的版本。或者https://www.anaconda.com/download/#linux官网下载地址,最新版本。
    (https://repo.continuum.io/archive/index.html)这里也有下载地址,可以使用命令下载,如下

     wget https://repo.continuum.io/archive/Anaconda3-5.3.0-Linux-x86_64.sh
    ##这是python3的,可以去上面的链接里,找到适合自己系统python版本的,比如
    #wget https://repo.continuum.io/archive/Anaconda2-5.3.0-Linux-x86_64.sh
    #按照需求自己选
    
    

    不添加镜像,或者添加清华镜像https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/好处是下载快(其实我感觉差不多速度)自行选择。清华镜像添加是执行下面几句

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    conda config --set show_channel_urls yes
    

    然后执行
    bash Anaconda2-5.1.0-Linux-x86_64.sh
    我官网下的最新版。
    然后一路回车,出现下面这个时候,输入yes.
    Do you accept the license terms? [yes|no] [no] >>> yes #这输入yes
    然后出现
    Do you wish the installer to prepend the Anaconda2 install location to PATH in your /home/wn/.bashrc ? [yes|no] [no] >>> yes #[no]的意思是默认no,这输入yes

    Appending source /home/wn/anaconda2/bin/activate to /home/wn/.bashrc
    A backup will be made to: /home/wn/.bashrc-anaconda2.bak
    

    需要重新开启新的服务器。

    如果这里不小心输入了no,会出现[Anaconda] command not found: conda
    解决方案:export PATH=~/anaconda3/bin:$PATH

    最后然后出现

    Anaconda is partnered with Microsoft! Microsoft VSCode is a streamlined
    code editor with support for development operations like debugging, task
    running and version control.
    To install Visual Studio Code, you will need:
      - Administrator Privileges
      - Internet connectivity
    
    Visual Studio Code License: https://code.visualstudio.com/license
    
    Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
    
    #让你安装VS,不安,输入no
    

    然后我们接下来创建虚拟环境

    # 创建一个名为S2P的环境,指定Python版本是2.7
    conda create --name S2P python=2.7
    
    #查看刚才创建的所有环境
    conda list env(指的是哪些包)
    conda info --envs(指的是创建环境的名称)
    
    # activate激活S2P
    source activate S2P
    # 激活后,会发现terminal输入的地方多了S2P的字样,实际上,此时系统做的事情就是把默认环境从PATH中去除,再把当前2.7加入PATH
    
    
    python --version
    # 可以看到系统已经切换到了2.7的环境
    
    # 如果想返回默认的python环境,运行
    
    source deactivate S2P
    
    
    # 删除刚才创建的环境S2P
    conda remove --name S2P --all
    
    

    接下来在虚拟环境中安装tensorflow
    anaconda search -t conda tensorflow #查看版本和资源

    image.png

    然后决定你想要下载哪个版本

     anaconda show cjj3779/tensorflow-gpu
    Using Anaconda API: https://api.anaconda.org
    Name:    tensorflow-gpu
    Summary: TensorFlow helps the tensors flow
    Access:  public
    Package Types:  conda
    Versions:
       + 1.4.0
    
    To install this package with conda run:
         conda install --channel https://conda.anaconda.org/cjj3779 tensorflow-gpu
    
    

    根据提示,我们可以执行
    conda install --channel https://conda.anaconda.org/cjj3779 tensorflow-gpu

    当然,也可以用conda直接装固定版本的tensorflow,使用conda装的好处是,不需要额外装一些包

    conda install --channel https://conda.anaconda.org/anaconda tensorflow=1.6.0
    或者conda install tensorflow-gpu=1.4.*
    
    

    或者
    (可以查看这个网站,下载比较受欢迎的tensorflow-gpu版本)[https://anaconda.org/search?q=tensorflow-gpu]

    当然,还可以选择清华的镜像站,但是有时候会不稳定,不显示你想要版本的.whl文件

    https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/
    #这里有各种资源,可以直接下在后缀名为.whl的tensorflow版本
    

    那么还有更好的方法,请移步与pypi,搜索tensorflow-gpu,找到你想要的版本

    https://pypi.org/
    
    tf.__version__
    tf.__path__
    

    执行上面两句话验证tensorflow,出现版本号就可以了

    可能出现的问题!command not found: conda
    解决方案:export PATH=~/anaconda3/bin:$PATH

    相关文章

      网友评论

        本文标题:linux-Anaconda+conda创建python-ten

        本文链接:https://www.haomeiwen.com/subject/qickrftx.html