【 python version : 3.9.13+vscode】环境搭建以及报错解决学习(一)

1、anaconda 环境的选择,新建,与查看

创建 conda create -n test1 python=3.9
查看 conda env list
激活 activate torch
退出 conda deactivate
删除在base环境下删除 conda remove -n test1 --all

操作如下:
【 python version : 3.9.13+vscode】环境搭建以及报错解决学习(一)_第1张图片

(base) C:\Users\Administrator>conda info -e
# conda environments:
#
base                  *  D:\softer\Aanaconda
torch                    D:\softer\Aanaconda\envs\torch


(base) C:\Users\Administrator>
(base) C:\Users\Administrator>activate torch

(torch) C:\Users\Administrator>activate base

(torch) C:\Users\Administrator>conda.bat activate base

(base) C:\Users\Administrator>activate torch

(torch) C:\Users\Administrator>conda info

     active environment : torch
    active env location : D:\softer\Aanaconda\envs\torch
            shell level : 4
       user config file : C:\Users\Administrator\.condarc
 populated config files : C:\Users\Administrator\.condarc
          conda version : 22.9.0
    conda-build version : 3.22.0
         python version : 3.9.13.final.0
       virtual packages : __cuda=11.8=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : D:\softer\Aanaconda  (writable)
      conda av data dir : D:\softer\Aanaconda\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : D:\softer\Aanaconda\pkgs
                          C:\Users\Administrator\.conda\pkgs
                          C:\Users\Administrator\AppData\Local\conda\conda\pkgs
       envs directories : D:\softer\Aanaconda\envs
                          C:\Users\Administrator\.conda\envs
                          C:\Users\Administrator\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/22.9.0 requests/2.28.1 CPython/3.9.13 Windows/10 Windows/10.0.19045
          administrator : False
             netrc file : None
           offline mode : False


(torch) C:\Users\Administrator>


(base) C:\Users\Administrator>conda env list
# conda environments:
#
base                  *  D:\softer\Aanaconda
test1                    D:\softer\Aanaconda\envs\test1
torch                    D:\softer\Aanaconda\envs\torch


(base) C:\Users\Administrator>activate test1

(test1) C:\Users\Administrator>conda list
# packages in environment at D:\softer\Aanaconda\envs\test1:
#
# Name                    Version                   Build  Channel
ca-certificates           2022.10.11           haa95532_0
certifi                   2022.9.24        py39haa95532_0
openssl                   1.1.1s               h2bbff1b_0
pip                       22.2.2           py39haa95532_0
python                    3.9.15               h6244533_2
setuptools                65.5.0           py39haa95532_0
sqlite                    3.40.0               h2bbff1b_0
tzdata                    2022f                h04d1e81_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.37.1             pyhd3eb1b0_0
wincertstore              0.2              py39haa95532_2

(test1) C:\Users\Administrator>conda env list
# conda environments:
#
base                     D:\softer\Aanaconda
test1                 *  D:\softer\Aanaconda\envs\test1
torch                    D:\softer\Aanaconda\envs\torch


(test1) C:\Users\Administrator>conda remove -n test1 --all

CondaEnvironmentError: cannot remove current environment. deactivate and run conda remove again


(test1) C:\Users\Administrator>cd
C:\Users\Administrator

(test1) C:\Users\Administrator>cd
C:\Users\Administrator

(test1) C:\Users\Administrator>activate base

(test1) C:\Users\Administrator>conda.bat activate base

(base) C:\Users\Administrator>conda remove -n test1 --all

Remove all packages in environment D:\softer\Aanaconda\envs\test1:


## Package Plan ##

  environment location: D:\softer\Aanaconda\envs\test1


The following packages will be REMOVED:

  ca-certificates-2022.10.11-haa95532_0
  certifi-2022.9.24-py39haa95532_0
  openssl-1.1.1s-h2bbff1b_0
  pip-22.2.2-py39haa95532_0
  python-3.9.15-h6244533_2
  setuptools-65.5.0-py39haa95532_0
  sqlite-3.40.0-h2bbff1b_0
  tzdata-2022f-h04d1e81_0
  vc-14.2-h21ff451_1
  vs2015_runtime-14.27.29016-h5e58377_2
  wheel-0.37.1-pyhd3eb1b0_0
  wincertstore-0.2-py39haa95532_2


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\Users\Administrator>conda env list
# conda environments:
#
base                  *  D:\softer\Aanaconda
torch                    D:\softer\Aanaconda\envs\torch

2、文件读取,要用到绝对路径

D:\Machine-Learning-master\Decision Tree\lenses.txt
#打开的文件名
filename = “D:\Machine-Learning-master\Machine-Learning-master\kNN\2.海伦约会\datingTestSet.txt”

3、多个环境

import os
os.environ[“KMP_DUPLICATE_LIB_OK”] = “TRUE”

4、报错Import “sklearn.externals.six” could not be resolvedPylancereportMissingImports

#from sklearn.externals.six import StringIO
from six import StringIO##修改

5、FontProperties=font 报错,拼写错误

【 python version : 3.9.13+vscode】环境搭建以及报错解决学习(一)_第2张图片
改为: fontproperties=font

6、中文文本分割

可以直接使用第三方分词组件,即jieba,没错就是"结巴"。

pip3 install jieba

【 python version : 3.9.13+vscode】环境搭建以及报错解决学习(一)_第3张图片

你可能感兴趣的:(python,vscode,学习)