程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Poetry: Python dependency management and packaging tool [The best Python virtual environment Poetry] [Poetry, conda, vscode mixed use]

編輯:Python

Poetry is a Python dependency management and packaging tool.It allows you to declare the libraries your project depends on and will manage (install/update) them for you.

Official website:
https://python-poetry.org/

There are three ways to install Poetry:

  • With the official installer
  • With pipx
  • With pip

It is officially recommended to use the official installation script, located at: https://python-poetry.org/docs/.

Note: The get-poetry.py script will be replaced by install-poetry.py in Poetry 1.2, it is recommended to use the latest version of the install script directly.This is done by selecting master in the version selection drop-down box at the top.

The default installation script on the official website is still get-poetry.py, during the installation process I noticed that the prompt message contains the following prompt: This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.

It was only then noticed that it was better to choose install-poetry.py.

Install

For Windows operating system, you need to enter under PowerShell

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

2. Mixed use of poetry, conda and vscode

1. Why use conda instead of the virtual environment management that comes with Poetry?

poetry can't create a different version of python, conda can

2, how to combine the two

First close poetry globally to create a virtual environment, be careful not to operate in the conda activated environment at this time

Turn off poetry's ability to create a virtual environment

poetry config virtualenvs.create false

Create a new conda virtual environment,

conda create -n myenv python=3.9

Enter it, execute

poetry env info

Make sure you are using the conda virtual environment, you should get results similar to the following

Then use poetry in the myenv environment created by conda, and refer to other people's articles.

VirtualenvPython: 3.8.11Implementation: CPythonPath: /data/user/anaconda3/envs/myenvValid: True



References:
What's wrong with mixing conda and poetry?
Python Development—Building a Virtual Python Development Environment (Conda+Poetry)
Basic use of poetry in Python package management
Python dependency management and packaging tool Poetry installation and testing
The best PythonThe virtual environment Poetry
poetry mixed with conda and vscode, trampled pits and summary
Poetry (2) Basic usage of Poetry


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved