Skip to main content

常用指令

插件​

使用 info 命令,可以查看当前项目的环境信息

pdm info --env

安装依赖​

pdm install -v

创建项目​

pdm init

切换python环境​

如果需要让pdm识别本地的其他python环境,将对应的环境的路径和Scripts放进系统环境编带Path中即可(window)

pdm use pythonxxx

pdm use {python_路径}

pdm use D:\CPS\python\Python3810\python.exe

指定源​

# 当前项目 相当于创建一个pdm.toml,添加配置pypi.url=xxxx
pdm config --local pypi.url https://pypi.tuna.tsinghua.edu.cn/simple

# 全局
pdm config pypi.url https://pypi.tuna.tsinghua.edu.cn/simple

配置文件中指定​

[pypi]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"

添加pip​

# 在虚拟环境中安装pip
pdm run python -m ensurepip

# 安装任意依赖项
# 这些依赖项不会与锁定文件中的依赖项进行冲突检查!
pdm run python -m pip install coverage

pdm run python -m pip install -r requirements.txt

或者你可以使用 --with-pip 在创建虚拟环境时包含 pip:

pdm venv create --with-pip 3.9

导出 requirements.txt​

pdm export -o ./requirements.txt