pycharm combined with Anaconda

Recently, I want to try to make some small things with python. I first download other people’s code on git. Everyone’s environment is different, so I use Anaconda to control the environment.

1. Install

Go directly to the official website to find it. If you can’t find it, use the link here. There are various versions, including historical versions. Basically, the next step is enough, pay attention to ticking directly here, or you need to manually increase the environment variable.
Click on Anaconda official website
insert image description here
, enter the command to see the current environment, as shown in the figure, there is only base, and the installation is complete.
insert image description here
insert image description here

2. Anaconda basic commands

The startup of anaconda is really very slow. Anyway, my computer is like this, so I use the command line to operate here.

#修改国内镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 
conda config --set show_channel_urls yes

#清除索引
conda clean -i

Find this file .condarc in the user directory. After modifying the content and saving it, remember to enter the clear index code conda clean -i, and then start the millisecond-level experience.
insert image description here

insert image description here

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  - http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
custom_channels:
  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
  ustc: http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  alibaba : https://mirrors.aliyun.com/pypi/simple/
 
ssl_verify: true
#升级
conda update conda 

#查看环境列表
conda env list

#创建虚拟环境(不指定路径)
conda create -n env_name(环境名称) python=3.8(对应的python版本号)

#创建虚拟环境(指定路径)
conda create --prefix=env_file(环境路径) python=3.8(对应的python版本号)
conda create -p env_file(环境路径) python=3.8(对应的python版本号)

#激活虚拟环境
conda activate env_name(环境名称)
#退出虚拟环境
conda deactivate env_name(环境名称)
#删除虚拟环境(删除前记得先退出环境)
conda remove -n env_name(环境名称) --all

3.pycharm uses anaconda


insert image description here
Just set the environment, click the File-setting setting, you can add the environment, and select your own anaconda environment
insert image description here
insert image description here

4. GitHub project run

All projects on github contain requirements.txt, which is used to record all dependent packages and their precise version numbers for deployment in new environments.

#生成命令(借助pipreqs工具)
pip install pipreqs
pipreqs ./ --encoding=utf-8 --force

#安装命令
pip install -r requirements.txt

#指定源安装
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

5. How to use python

5.1 The generated csv has an extra column of unamed

insert image description here

This is to generate an additional index column when reading. In fact, we don’t need it, just add index_col=0

data = pd.read_csv(csv_name, nrows=11, index_col=0)

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43487532/article/details/127546527