开发Python

Python很热,广告一堆吹,听起来有点懵,不过,Python 项目确实很多,AI类的比较集中

=== 安装篇 ===

常规开发环境,anaconda
https://www.anaconda.com/products/individual 这个是个人版(免费)下载地址
https://docs.conda.io/en/latest/miniconda.html miniconda 精简版
下载地址https://www.anaconda.com/download/success

安装conda 后可执行,


查看源
conda config --show-sources
添加仓库
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
第三方源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
删除源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

换回默认源:conda config --remove-key channels
清华曾停止服务, 而且有时也不一定能快
近期在装 conda install geopandas 就不能使用第三方源,换回默认源后即可正常安装

使用 SJTUG源


官方源
pkgs/free:   conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free
pkgs/main:   conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main
pkgs/mro:    conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/mro
pkgs/msys2:  conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/msys2
pkgs/pro: (deprecated) conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/pro
pkgs/r: (empty) conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/r
第三方源:
cloud/bioconda: conda config --set custom_channels.bioconda https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/conda-forge: conda config --set custom_channels.conda-forge https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/menpo: conda config --set custom_channels.menpo https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/soumith: conda config --set custom_channels.soumith https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/viscid-hub: conda config --set custom_channels.viscid-hub https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/atztogo: conda config --set custom_channels.atztogo https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/pytorch: conda config --set custom_channels.pytorch https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
cloud/pytorch-test: conda config --set custom_channels.pytorch-test https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/


安装目录参考 C:\cmdcons\Anaconda3

打开 Anaconda Prompt (Anaconda3)
执行
镜像地址可以考虑其他的,看喜好吧,


pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set global.trusted-host mirrors.aliyun.com
python --version

深圳马版本


pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
pip config set global.trusted-host mirrors.cloud.tencent.com
pip install pip -U
python --version


conda创建Python27的环境

 
python --version
conda create -n py27 python=2.7
conda activate py27
python --version
conda create -n py37 python=3.7
conda activate py37
python --version

常用科学计算的库

 
pip install numpy scipy pandas matplotlib scikit-learn

=== 错误篇===

AttributeError: type object ‘Callable’ has no attribute ‘_abc_registry’
错误:Rasa init –no-prompt 报错
原因:Python升级到3.7后会遇到该问题
解决:pip uninstall typing

=== 项目案例篇 ===

===
https://github.com/DLR-RM/stable-baselines3

pip install PyHamcrest cloudpickle numpy 
pip install stable-baselines3