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:\Users\33488\Documents'

 

 

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:\Ksoftware\Anaconda2

這兩條內容不能與已存在的環境重復。

 

如果出現報錯, 提示哪個文件夾沒權限、找不到 或是 不存在, 但是你發現可以找到!  那么就將那個文件夾刪掉, 重新創建新環境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 + \beta $ 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_width: 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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM