展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

vscode编写python

  • 安装插件

  • 打开cmd创建虚拟环境

C:\Users\ychen>conda create -n env_dev python=3.10.4
Fetching package metadata .................
Solving package specifications: .

Package plan for installation in environment C:\ProgramData\Anaconda3\envs\env_dev:

The following NEW packages will be INSTALLED:

    bzip2:           1.0.8-h2bbff1b_5       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ca-certificates: 2023.12.12-haa95532_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    libffi:          3.4.4-hd77b12b_0       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    openssl:         1.1.1w-h2bbff1b_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    pip:             23.3.1-py310haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    python:          3.10.4-hbb2ffb3_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    setuptools:      68.2.2-py310haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    sqlite:          3.41.2-h2bbff1b_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    tk:              8.6.12-h2bbff1b_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    tzdata:          2024a-h04d1e81_0       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    vc:              14.2-h21ff451_1        https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    vs2015_runtime:  14.27.29016-h5e58377_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    wheel:           0.41.2-py310haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    xz:              5.4.6-h8cc25b3_0       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    zlib:            1.2.13-h8cc25b3_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

Proceed ([y]/n)? y

tzdata-2024a-h 100% |###############################| Time: 0:00:00 615.02 kB/s
bzip2-1.0.8-h2 100% |###############################| Time: 0:00:00   3.09 MB/s
tk-8.6.12-h2bb 100% |###############################| Time: 0:00:00   7.38 MB/s
xz-5.4.6-h8cc2 100% |###############################| Time: 0:00:00  12.65 MB/s
zlib-1.2.13-h8 100% |###############################| Time: 0:00:00   8.77 MB/s
python-3.10.4- 100% |###############################| Time: 0:00:01  11.20 MB/s
setuptools-68. 100% |###############################| Time: 0:00:00  11.79 MB/s
wheel-0.41.2-p 100% |###############################| Time: 0:00:00   0.00  B/s
pip-23.3.1-py3 100% |###############################| Time: 0:00:00  11.51 MB/s
#
# To activate this environment, use:
# > activate env_dev
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#


C:\Users\ychen>conda info -e
# conda environments:
#
env_dev                  C:\ProgramData\Anaconda3\envs\env_dev
root                  *  C:\ProgramData\Anaconda3


C:\Users\ychen>activate env_dev

(env_dev) C:\Users\ychen>pip list
Package    Version
---------- -------
pip        23.3.1
setuptools 68.2.2
wheel      0.41.2

(env_dev) C:\Users\ychen>pip install Numpy
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting Numpy
  Downloading https://mirrors.aliyun.com/pypi/packages/19/77/538f202862b9183f54108557bfda67e17603fc560c384559e769321c9d92/numpy-1.26.4-cp310-cp310-win_amd64.whl (15.8 MB)
     ---------------------------------------- 15.8/15.8 MB 10.1 MB/s eta 0:00:00
Installing collected packages: Numpy
Successfully installed Numpy-1.26.4

(env_dev) C:\Users\ychen>pip list
Package    Version
---------- -------
numpy      1.26.4
pip        23.3.1
setuptools 68.2.2
wheel      0.41.2
  • 打开1个文件夹作为项目文件夹
  • Ctrl+P打开命名面板,输入如下命令
> select interpreter
  • 选择解释器

  • 选择虚拟环境

  • 右下角也可以选择

  • 点击右上角执行

posted @ 2024-03-09 10:38  DogLeftover  阅读(26)  评论(0编辑  收藏  举报