1 创建环境
conda create -n new python=3.7 //这里的环境名称为new
2 激活环境:
conda activate new
3 设置conda下载的源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
4 设置pip下载的源:
1) 一次性修改
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests
2) 永久修改
windows下,直接在user目录的用户名目录下创建一个pip目录,如:你的用户名是Administrator,则新建C:\Users\Administrator\pip,
并在里面新建文件pip.ini。内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
5 安装各种模块:
(如果用conda install安装,安装的模块版本较低)
pip install numpy
pip install matplotlib
6查看Python环境
conda info --env可以看到所有python环境,前面有个‘*’的代表当前环境:
7管理和使用python环境
使用conda activate new 来激活刚才创建的环境:
尝试使用pip install numpy来给这个环境安装一个常用的包:
当然也可以用conda install numpy来安装,但是会同时安装很多相关的包,在此就不演示了。
在简单的熟悉了以后,就会发现用anaconda来进行python环境的控制真的是非常方便,其实anaconda环境是有物理路径的,如下,你会发现这和我们之前conda info --env的list是一样的:
之后我们删除new : conda remove -n new --all
去路径下查看文件夹会发现new已经被删除了
再用conda info --env进入查看也查看不到了