超详细版miniconda的安装,创建虚拟环境,配置Vscode

文章目录

  • 前言
    • 配置环境
      • 安装 vscode
      • 安装 miniconda
      • 配置虚拟环境
      • 在VScode 使用虚拟环境
    • 运行程序
      • 程序1
      • 程序2
  • 参考链接

前言

配置环境

安装 vscode

Pycharm 体积过大,而且兼容性也不如 VScode,所以优先安装 VScode

  • 官网链接:https://code.visualstudio.com/download

在这里插入图片描述

选择自己系统对应的下载链接

安装成功后,安装 Python 相关插件

在这里插入图片描述

也可以选择汉化

在这里插入图片描述

建议安装 C++插件

在这里插入图片描述

安装 miniconda

我觉得 Anaconda 太大了,而且它的图形化界面我也不喜欢,操作起来也比较慢,在这里推荐使用 miniconda

在这里插入图片描述

选择自己系统对应的下载链接

官网可能比较卡,推荐使用镜像源

在这里插入图片描述

默认安装,注意这一步要勾选环境变量

img

  • 验证是否安装成功:

在菜单栏中直接打开或搜索 Anaconda Prompt

在这里插入图片描述在这里插入图片描述

安装成功

  • 查看 conda 版本

在终端输入命令

conda --version

在这里插入图片描述

配置虚拟环境

虚拟环境,就是把我们安装的 python 包集成化起来,环境与环境之间不会相互影响,人性化管理

  • 打开 Anaconda Prompt,后续操作都在这个终端进行

在这里插入图片描述

  1. 创建虚拟环境

    python建议使用 3.9 版本,版本太高,后续配其他包时会出现 bug

    conda create -n text python=3.9
    

    在这里插入图片描述

  2. 激活虚拟环境

    conda activate text
    

    在这里插入图片描述

  3. 配置镜像源

    我使用的是清华源

    • 临时指定镜像源下载

      pip install 包名  -i https://pypi.tuna.tsinghua.edu.cn/simple numpy
      
    • 设置为全局

      conda config --add channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
      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/r
      conda config --add channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
      conda config --add channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 
      
      
    • 查看已经添加的镜像源

      conda config --show channels
      

      在这里插入图片描述

  4. 安装Python功能包

    pip install numpy
    pip install matplotlib
    

在这里插入图片描述

  1. 查看安装的包

    pip list
    

在这里插入图片描述

在VScode 使用虚拟环境

打开命令面板。选择 “Python:选择解释器”。

在这里插入图片描述

在这里插入图片描述

环境配置成功,YES!

运行程序

程序1

  • 要求:运行打印“hello, world”程序;

  • 源码:

    print("hello,world")
    
  • 运行截图

在这里插入图片描述

程序2

  • 要求:导入扩展库numpy,matplotlib,绘制sin曲线

  • 源码:

    import numpy as np
    import matplotlib.pyplot as plt
    
    # 定义x的范围
    x = np.linspace(0, 4 * np.pi, num=512)
    
    y = np.sin(x)
    
    # 绘制sin曲线,添加颜色、线型和标签
    plt.plot(x, y, color='blue', linestyle='--', label='sin(x)')
    
    # 添加标题和坐标轴标签
    plt.title('Sine Wave')
    plt.xlabel('x values (radians)')
    plt.ylabel('sin(x)')
    
    # 显示图例
    plt.legend()
    
    # 优化图形显示
    plt.grid(True)
    plt.tight_layout()
    
    # 展示图形
    plt.show()
    
    
  • 运行截图:

    在这里插入图片描述

参考链接

VSCode 安装配置使用教程(最新版超详细保姆级含插件)一文就够了_vscode 使用教程-CSDN 博客

超详细版 Anaconda 的安装及使用 conda 创建、运行虚拟环境以及使用镜像源_anaconda 镜像源-CSDN 博客

Miniconda 安装及使用 for windows(保姆级教程)-CSDN 博客

pip临时使用清华镜像源_pip 临时使用清华源-CSDN博客

Miniconda 安装及使用 for windows(保姆级教程)-CSDN 博客

pip临时使用清华镜像源_pip 临时使用清华源-CSDN博客

【Conda+vsCode】vsCode 中使用 conda 配置虚拟环境_vscode conda-CSDN博客

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值