笔记笔记
  • Home
  • AI&ML
  • Example
  • Zoo
  • 关于
⌘ K
常用命令 - 返回
Shell 软件
iTerm
Homebrew
macOS 制作 U 盘 启动
DNS
系统工具
Python 环境
桌面软件
VMware Fusion
最后更新时间:
Copyright © 2023-2024 | Powered by dumi | GuoDapeng | 冀ICP备20004032号-1 | 冀公网安备 冀公网安备 13024002000293号

TABLE OF CONTENTS

Python 环境

Poetry

Poetry 官方文档

安装

shell
brew install poetry
# 卸载 poetry
brew uninstall poetry
cd ~/Library/Caches
rm -r pypoetry

配置

shell
# 查看配置
poetry config --list
# 设置虚拟环境在项目目录
poetry config virtualenvs.in-project true
# 查看配置
poetry config virtualenvs.in-project

默认的虚拟环境目录:~/Library/Caches/pypoetry/virtualenvs

在项目内,使用 poetry env info 查看虚拟环境信息。

虚拟环境

shell
# 创建 python3 环境
poetry env use python3
# 激活虚拟环境
source .venv/bin/activate
# 退出虚拟环境
deactivate

创建项目

shell
# 创建项目
poetry new StructBERTTrain
# 设置虚拟环境在项目目录
poetry config virtualenvs.in-project true
# 设置镜像源
poetry source add --priority=primary mirrors https://pypi.tuna.tsinghua.edu.cn/simple/
# 创建虚拟环境
poetry env use python3
# 进入虚拟环境
source .venv/bin/activate
# 安装依赖
poetry add fastapi
poetry add notebook --group dev