Henry
发布于 2025-11-30 / 9 阅读
0
0

Poetry - 新建项目

背景简介

使用 poetry 新建和管理项目

前置信息

详细信息

**第一步:**新建项目

poetry new pers-ai-agentic
Created package pers_ai_agentic in pers-ai-agentic
  • 初始文件结构
.
├── pyproject.toml
├── README.md
├── src
│   └── pers_ai_agentic
│       └── __init__.py
└── tests
    └── __init__.py

第二步: 创建虚拟环境并安装依赖

poetry install
Creating virtualenv pers-ai-agentic-CiOuYQox-py3.13 in /Users/user/Library/Caches/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Installing the current project: pers-ai-agentic (0.1.0)

可选: 激活虚拟环境

poetry shell
Looks like you're trying to use a Poetry command that is not available.

Since Poetry (2.0.0), the shell command is not installed by default. You can use,

  - the new env activate command (recommended); or
  - the shell plugin to install the shell command

Documentation: https://python-poetry.org/docs/managing-environments/#activating-the-environment

Note that the env activate command is not a direct replacement for shell command.

可选: 执行脚本

poetry run python your_script.py

以上便是本文的全部内容,感谢您的阅读,如遇到任何问题,欢迎在评论区留言讨论。



评论