anaconda + VSCode + 生产环境配置

1. 修改jupyter notebook 默认路径:

进入anaconda 命令行, jupyter notebook --generate-config   生成配置文件, 该文件在    本机用户名/.jupyter 下。

进入jupyter_notebook_config.py 找到

## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'C:Users33488Documents'

2. 添加国内资源镜像

#清华
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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 --set show_channel_urls yes

# 中科大
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes

conda config --add channels https://anaconda.org/

# 删除源
conda config --remove channels https://error…… 

conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
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.ustc.edu.cn/anaconda/pkgs/main/
conda config --remove channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --remove channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --remove channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --remove channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
 

  

弄这些没有用的。。。  更新版本最好的办法还是重装anaconda, 不要自己乱更新!!!!!  切记!!!!!

安装conda 找不到的包  pip install imgaug

卸载第三方库  conda uninstall ....

 安装cv2 

conda install -c https://conda.binstar.org/menpo opencv

labelImg  windows + anaconda :  https://blog.csdn.net/qq_32799915/article/details/79081659

 

3. anaconda 导出环境,  在其他机器安装。

conda env export > environment.yaml

conda env create -f environment.yaml

在导入配置文件时需要注意修改一些内容:   

name: test2

prefix: E:KsoftwareAnaconda2

这两条内容不能与已存在的环境重复。

如果出现报错, 提示哪个文件夹没权限、找不到 或是 不存在, 但是你发现可以找到!  那么就将那个文件夹删掉, 重新创建新环境base3....

我是直到base3才安装完成,  下面就要激活该环境, 并将其他环境删除。

conda remove -n base2 --all

激活环境:  linux:  source activate base3         windows:     activate base3                   事实上已经激活了。

安装openai gym:

conda install -c conda-forge pip

pip install msgpack

pip install gym

###########################Jupyter使用######################################################

1. 回车键 标记行,进入编辑模式; m键 标记行, 配置标题级别1-6;
2. 插入数学公式, $sum alpha + eta $ http://latex.codecogs.com/eqneditor/editor.php

###########################VSCODE########################################################

不要使用anaconda自带的VSCode。 

VSCode中是使用F5 执行。

conda install pylint yapf
conda install django


最左侧 最下角的配置:
{
    "python.dataScience.sendSelectionToInteractiveWindow": true,
    "python.pythonPath": "E:/software/Anaconda/pythonw.exe",
    "python.autoComplete.extraPaths": [
        "E:/software/Anaconda/python",
        "E:/software/Anaconda/Lib/site-packages",
        "E:/software/Anaconda/Scripts",
    ],
    //"python.linting.flake8Enabled": true,
    "python.linting.pylintEnabled": true,
    "python.formatting.provider": "yapf",
    "python.formatting.yapfArgs": [
        "--style",
        "{based_on_style: chromium, indent_ 4}"
    ],
    "python.linting.pylintArgs": [
        "--load-plugins",
        "pylint_django"
    ],
}



新建一个文件夹, 使用命令行:
django-admin startproject django_test

进入项目内部, 创建mvc
python manage.py startapp app_name

点击 Debug -> open Config
"args": [
                "runserver",
                "8080",
                "--noreload",
                "--nothreading"
            ],
			
最后: 在最左侧倒数第二栏, 配置Python:Django,  按F5后即可运行。

  

########################生产环境配置##########################################################

yum install -y bzip2

bash Anaconda3-2019.03-Linux-x86_64.sh

安装在/data/anaconda下

source ~/.bashrc  更新一下环境变量。

python -v时发现, 版本3.7。

解决anaconda与系统自带python冲突问题:

在/etc/profile中:

alias python="/usr/bin/python"

alias conda-python="/data/anaconda/bin/python"

export CONDA_HOME=/data/anaconda

export PATH=$JAVA_HOME/bin:$SCALA_HOME/bin:$CONDA_HOME/bin:$PATH

创建环境名字(比如项目代码的名字)并指定python版本
conda create --name ASR python=3.6
激活环境
source activate ASR

技术激情,追求极致! 技术交流: rli07@foxmail.com
原文地址:https://www.cnblogs.com/ruili07/p/9571944.html