美文网首页
Aancconda使用技巧总结

Aancconda使用技巧总结

作者: thirsd | 来源:发表于2019-08-18 00:32 被阅读0次

    一、更新源为国内源

    TUNA 还提供了 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
    

    Anaconda 中科大源

    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
    conda config --set show_channel_urls yes
    

    类似直接修改文件(用户的家目录下的.condarc):
    windows: C:\Users\thirsd.condarc
    Linux : ~/.condarc
    配置文件格式如下:

    channels:
     - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
      - defaults
    show_channel_urls: true
    ssl_verify: true
    

    二、更新cronda

    更新最新包:
    conda update -n base -c defaults conda

    三、pip配置和更新

    1、临时替换源
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
    2、永久替换
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

    修改配置文件:
    linux : ~/.config/pip/pip.conf (Linux)
    windows: %APPDATA%\pip\pip.ini
    例如,我的配置路径:C:\Users\thirsd\AppData\Roaming\pip\pip.ini

    文件格式如下:

    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    

    验证执行:
    pip install numpy

    (base) C:\WINDOWS\system32>pip install numpy
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Collecting numpy
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/26/26/73ba03b2206371cdef62afebb877e9ba90a1f0dc3d9de22680a3970f5
    a50/numpy-1.17.0-cp37-cp37m-win_amd64.whl (12.8MB)
         |████████████████████████████████| 12.8MB 2.2MB/s
    Installing collected packages: numpy
    Successfully installed numpy-1.17.0
    

    四、设置jupyter密码

    1、在anaconda-promt窗口中,生成配置文件

    (base) C:\Users\thirsd>jupyter notebook --generate-config
    Writing default config to: C:\Users\thirsd\.jupyter\jupyter_notebook_config.py
    
    (base) C:\Users\thirsd>
    
    • Windows: C:\Users\USERNAME.jupyter\jupyter_notebook_config.py

    • OS X: /Users/USERNAME/.jupyter/jupyter_notebook_config.py

    • Linux: /home/USERNAME/.jupyter/jupyter_notebook_config.py

    2、输入ipython,打开交互窗口,生成密码:

    (base) C:\Users\thirsd>ipython
    Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: from notebook.auth import passwd
    
    In [2]: passwd()
    Enter password:  yourpassword
    Verify password:  yourpassword
    Out[2]: 'sha1:b9965270cd9b:84ae5b1512d3cd8677f0f3d0f9cea133f1ef7851'
    
    In [3]:
    
    

    3、修改配置文件
    在文件C:\Users\thirsd.jupyter\jupyter_notebook_config.py中,增加:
    c.NotebookApp.password = u'sha1:b9965270cd9b:84ae5b1512d3cd8677f0f3d0f9cea133f1ef7851'

    相关文章

      网友评论

          本文标题:Aancconda使用技巧总结

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