【Conda】python environment setup , windows+conda+jupyter+pytorch (English Version)

little girl 2022-08-06 06:32:57 阅读数:568


Install anaconda

  1. Enter the official website of Anaconda:https://www.anaconda.com/
  2. Left click download
  3. Double left click the file after downloading,the result should be:
  4. Keep clicking next util this part:
    Check add anaconda3 to my PATH environment varible
  5. Installation done
    在这里插入图片描述7. Check whether anaconda has been successfully installed:
    Search cmd on the left bottom of screen
    open cmd, type conda, conda has been successfully installed if it gives you like this:

Create conda environment

  1. Create a new environment named tutorial (setup python version as 3.6)
    conda create -n tutorial python=3.6
    Successfully create:在这里插入图片描述

Activate environment

  1. Activate environment tutorial
    conda activate tutorial
    Successfully activate:

Install jupyter notebook

  1. install
    conda install jupyter
  2. open jupyter notebook
    jupyter notebook

Install pytorch

  1. Enter the official website of pytorch:https://pytorch.org/
  2. Choose the version you need, then copy the installation command.
    在这里插入图片描述4. In cmd, activate the environment you would like to install pytorch into. Then enter the command you copied before.Here I use cpu version pytorch for an example:
    conda install pytorch torchvision torchaudio cpuonly -c pytorch
  3. Check wether pytorch has been successfully installed:
    import torch
    The result should be like this if successfully installed:

Replace channel(If need)

Mirror channel is used when you can’t download some package due to the fire wall of China.

  1. Create condarc file:
    conda config --add channels r
  2. The condarc file should be in : /home/user/.condarc
  3. Find the file and open it, the content of the file should be like this:
  4. Use the content below to replace the content of condarc file:
    - defaults
    show_channel_urls: true
    channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
    conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
    msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
    bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
    menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
    pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
    simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
版权声明:本文为[little girl]所创,转载请带上原文链接,感谢。 https://pythonmana.com/2022/218/202208060519291335.html