Anaconda installation on Mac and configure PyCharm

Anaconda installation on Mac and configure PyCharm

  • I never wrote python, did not install any relevant IDE, here to make a record

Anaconda installation

  • From the official website to download, here chose Python3.7 graphical version of the installation package

  • After installation, enter the command line conda --version, if the installation is successful, it will display the version number

  • But I did not show, so according to Anaconda Python's environment configuration (Mac version) to configure the environment variables:

  • First of all, find the location of bin files in the installation path Anaconda, my path/opt/anaconda3/bin

    (Re-recorded it in the finder of the "Show", select the "Show Path Bar", you can display the current position)

  • Modify .bash_profilefile

    vim .bash_profile
    
  • Add the following statement after save and exit (PATH's address is the address of the bin file)

    export PATH="/opt/anaconda3/bin:$PATH"
    

  • Enter the command line, just to make documents take effect immediately

    source $HOME/.bash_profile
    
  • Test again conda --versionand found success shows the version number

  • Recorded at the relevant command anaconda's (Environmental Management section)

    # 环境管理
    # 查看当前conda版本
    conda --version
    # 查看当前所有环境(*表示当前所在环境) conda env list # 创建新的环境(version替换为相应python版本号) conda create -n EnvName python=version # 切换环境 source activate EnvName # 退出环境 conda deactivate # 移除指定的环境 conda remove -n EnvName --all 
  • Part of the package management command

    # 包管理
    # 查看当前环境中的包
    conda list
    # 查看指定环境下的包 conda list -n EnvName # 查找指定的包 conda search PacketName # 安装指定的包 conda install PacketName # 卸载指定的包 conda remove PacketName 
  • Modify conda source: anaconda default source address in a foreign country, when the download speed may be slow. We will modify it to domestic mirror, here I chose Tsinghua mirror. Note Tsinghua mirrored in 19 years on April 16 to stop the service, but in 19 years July 21 has been restored, you can continue to use. Directly on the command line, type the following command:

    # 添加清华conda源镜像
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    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/r
    # 添加清华的pytorch镜像(可能会用到,可选)
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
    # 设置搜索时显示通道地址 conda config --set show_channel_urls yes 
  • Others might use the following command:

    # 恢复默认源地址
    conda config --remove-key channels
    # 查看conda的config设置
    conda config --show
    # 查看当前conda的channel conda config --show channels 

Configured on PyCharm

  • Prior to this, we should use conda create -n EnvName python=versionto create a good environment for a version of python, for example, I use conda create -n test1py3.7 python=3.7to create an environment called test1py3.7

  • Open PyCharm, select Create New Project

  • Modify the project name, and then select Project Interpreter "Existing Interpreter> ...

  • In the new interface that appears, select Conda Environment == "...

  • Here, we are in before anaconda3 directory, choose to create a good test1py3.7> bin> python3.7 under envs folder, OK

  • Once selected, the following screen, select OK, then Create, waiting to create a good project

  • Create a python file, enter

    print("Hello World!")
    
  • Right the .py file, select Run, success

Modify PyCharm interpreter

  • Click PyCharm == "Preferences ...

  • In the search input box interpreter, select Project Interpreter, you can view the currently selected interpreter and related packages, and make changes

reference

Guess you like

Origin www.cnblogs.com/c-x-a/p/12575473.html