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_profile
filevim .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 --version
and 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=version
to create a good environment for a version of python, for example, I useconda create -n test1py3.7 python=3.7
to 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
- The Anaconda Python environment configuration (Mac version)
- Mac anaconda installation and basic commands
- python ubuntu 18.04 build environment (pycharm + anaconda)
- Anaconda mirroring Help
- conda source configuration
- Anaconda available domestic source of domestic source transducer and mirror sites Method
- Set mirror source of domestic Conda
- Original: https://www.cnblogs.com/xrblog/p/11839393.html