{{format('0')}} {{format('341')}} {{format('1793')}}

【PY模块】Miniconda 和 poetry 搭建 Python 开发环境(支持多版本、依赖管理) [ 编程杂谈 ]

大数据男孩 文章 正文

想做一个技术博客,奈何实力不够
分享

明妃

{{nature("2022-08-14 17:23:20")}}更新

说明

思想:用 Miniconda 管理多个Python版本,在使用 poetry 创建虚拟环境的时候,指定 Miniconda 环境里的Py版本

使用前的准备

安装 Miniconda

链接:https://docs.conda.io/en/latest/miniconda.html

安装 poetry

链接:https://bigdataboy.cn/post-399.html

创建环境

使用 Miniconda 创建多个Py版本的环境

创建不同 Python 版本的虚拟环境

conda create -n Py3.9 python=3.9

查看环境

conda env list

[mark]()

使用

第一步

初始化 poetry ,使用命令:poetry init,如果不是新项目直接 跳到第二步

这里有个坑,poetry 指定 Py版本的时候,只好写成这种格式 ~3.8 (支持 3.8. < 3.9.0 ),不然会报版本不一致的错误,原因就是 conda 下载的版本是3.8.x,两处版本支持范围要严格一直

F:\Tools\pyCode\test>poetry init

This command will guide you through creating your pyproject.toml config.

Package name [test]:
Version [0.1.0]:
Description []:
Author [‘zbigdataboy‘ <876545500@qq.com>, n to skip]:  bigdataboy
License []:
Compatible Python versions [^3.9]:  ~3.8

Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file

[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["bigdataboy"]

[tool.poetry.dependencies]
python = "~3.8"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Do you confirm generation? (yes/no) [yes] yes

第二步

peotry 使用指定的解释器

如果报 版本不一致的错误,看 第一步的 坑

poetry env use D:\ProgramData\miniconda3\envs\Py3.8\python.exe

[mark]()

第三步

安装相关依赖

poetry install
评论 0
0
{{userInfo.data?.nickname}}
{{userInfo.data?.email}}
TOP 2
Spark 2.0 单机模式与集群模式 安装

{{nature('2020-01-02 16:47:07')}} {{format('12522')}}人已阅读

TOP 3
Office 2016 Pro Plus 激活

{{nature('2019-12-11 20:43:10')}} {{format('9410')}}人已阅读

TOP 4
Linux上 MySQL 开启远程登陆的两种方法

{{nature('2019-12-26 17:20:52')}} {{format('7405')}}人已阅读

TOP 5
Linux 安装 MySQL 5.7

{{nature('2019-12-26 16:03:55')}} {{format('4880')}}人已阅读

目录

标签云

Python 包管理 模块

一言

# {{hitokoto.data.from || '来自'}} #
{{hitokoto.data.hitokoto || '内容'}}
作者:{{hitokoto.data.from_who || '作者'}}
自定义UI
配色方案

侧边栏