Python虚拟环境指南2022版本

本文介绍了Python的PDM虚拟环境管理,包括安装、初始化和包管理。接着详细讲解了Go开发环境的安装、项目依赖管理和版本升级。此外,还探讨了Rust的安装、Cargo的使用以及依赖管理。最后提到了Rust的版本升级流程。
摘要由CSDN通过智能技术生成

PDM 介绍

mac 上直接使用 brew install pdm 安装,其它系统官方提供了一个一键安装的shell脚本。安装完成后,创建一个项目目录 test-pdm ,在目录中使用 pdm init 命令初始化项目:

➜  test-pdm pdm init
Creating a pyproject.toml for PDM...
Please enter the Python interpreter to use
0. /usr/local/opt/python@3.9/bin/python3.9 (3.9)
1. /Library/Developer/CommandLineTools/usr/bin/python3 (3.8)
2. /Library/Frameworks/Python.framework/Versions/Current/bin/python3.8 (3.8)
3. /usr/local/bin/pypy3.7 (3.7)
4. /usr/local/bin/pypy (2.7)
5. /usr/local/Cellar/pdm/2.1.2/libexec/bin/python3.10 (3.10)
Please select (0): 2
Using Python interpreter: /Library/Frameworks/Python.framework/Versions/Current/bin/python3.8 (3.8)
Would you like to create a virtualenv with /Library/Frameworks/Python.framework/Versions/Current/bin/python3.8? [y/n] (y): y
Virtualenv is created successfully at /Users/yoo/tmp/test-pdm/.venv
Is the project a library that will be uploaded to PyPI [y/n] (n): n
License(SPDX name) (MIT):
Author name (game404):
Author email (studyoo@foxmail.com):
Python requires('*' to allow any) (>=3.8):
Changes are written to pyproject.toml.

pdm比较方便的地方是会扫描出系统的python解释器,提示用户选择解释器版本, 比如上面日志显示有5个python版本,有点乱:( 。初始化完成后,生成项目描述文件pyproject.toml内容如下:

[project]
name = ""
version = ""
description = ""
authors = [
    {name = "game404", email = "studyoo@foxmail.com"},
]
dependencies = []
requires-python = ">=3.8"
license = {text = "MIT"}

[build-system]
requires = ["pdm-pep517>=1.0.0"]
build-backend = "pdm.pep517.api"
复制代码

当然在项目目录下,也会创建一个隐藏的 .venv 目录,用来存放解释器,和其它工具一致。

安装包之前先使用 pdm config pypi.url https://pypi.tuna.tsinghua.edu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值