【筆記】Poetry虛擬環境創建示例

#工作記錄

【筆記】結合 Conda任意創建和配置不同 Python 版本的雙軌隔離的 Poetry 虛擬環境-CSDN博客

在PowerShell中:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindowsLoading personal and system profiles took 3890ms.
(base) PS C:\Users\love> conda activate python311
(python311) PS C:\Users\love> cd F:\PythonProjects\test3
(python311) PS F:\PythonProjects\test3> & "D:\ProgramData\anaconda3\envs\python311\Scripts\poetry.exe" config virtualenvs.create true
(python311) PS F:\PythonProjects\test3> & "D:\ProgramData\anaconda3\envs\python311\Scripts\poetry.exe" initThis command will guide you through creating your pyproject.toml config.Package name [test3]:  test3
Version [0.1.0]:
Description []:
Author [love530love <love530love@qq.com>, n to skip]:
License []:
Compatible Python versions [>=3.11]:Would you like to define your main dependencies interactively? (yes/no) [yes] yesYou can specify a package in the following forms:- A single name (requests): this will search for matches on PyPI- A name and a constraint (requests@^2.23.0)- A git url (git+https://github.com/python-poetry/poetry.git)- A git url with a revision         (git+https://github.com/python-poetry/poetry.git#develop)- A file path (../my-package/my-package.whl)- A directory (../my-package/)- A url (https://example.com/packages/my-package-0.1.0.tar.gz)Package to add or search for (leave blank to skip):Would you like to define your development dependencies interactively? (yes/no) [yes] yes
Package to add or search for (leave blank to skip):Generated file[project]
name = "test3"
version = "0.1.0"
description = ""
authors = [{name = "*****",email = "*****@q q.com"}
]
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
][build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"Do you confirm generation? (yes/no) [yes] yes
(python311) PS F:\PythonProjects\test3>

過程解讀

這段 PowerShell 操作記錄完整展示了在 Conda 環境下使用 Poetry 初始化項目的過程,每個步驟都與 Windows 系統下 PowerShell 的特性緊密相關,以下是逐行解讀:

  1. 啟動 PowerShell 并加載配置

?

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindowsLoading personal and system profiles took 3890ms.

這部分是 PowerShell 的啟動信息,提示用戶當前使用的是 Windows PowerShell,展示了版權聲明、升級提示以及加載個人和系統配置文件所花費的時間。這些信息與后續的 Python 環境管理操作無直接關聯,但提供了操作的基礎環境背景。


2.?激活 Conda 環境

?

(base) PS C:\Users\love> conda activate python311
(python311) PS C:\Users\love>

(base) PS C:\Users\love>?表示當前處于 Conda 的基礎環境。
conda activate python311?命令用于激活名為?python311?的 Conda 環境,激活成功后,命令提示符前綴變為?(python311) PS C:\Users\love>,表明后續操作將在?python311?環境中執行。
這一步是為后續使用該環境中的 Python 和 Poetry 工具做準備,確保操作在指定的 Python 版本環境下進行 。


3.?切換到項目目錄

?

(python311) PS C:\Users\love> cd F:\PythonProjects\test3
(python311) PS F:\PythonProjects\test3>

cd F:\PythonProjects\test3?命令將當前工作目錄切換到?F:\PythonProjects\test3,后續的 Poetry 操作將基于此目錄進行,確保項目相關文件(如?pyproject.toml)生成在正確的位置。


4.?配置 Poetry 虛擬環境創建

?

(python311) PS F:\PythonProjects\test3> & "D:\ProgramData\anaconda3\envs\python311\Scripts\poetry.exe" config virtualenvs.create true

在 PowerShell 中,使用?&?符號調用可執行文件(這里是 Poetry 的可執行文件?poetry.exe),config virtualenvs.create true?命令配置 Poetry,使其自動創建虛擬環境。如果不使用?&?符號,PowerShell 會將其視為普通字符串,導致語法錯誤。這一步配置是為了讓 Poetry 在后續初始化項目時,自動為項目創建獨立的虛擬環境。


5.?初始化 Poetry 項目

?

(python311) PS F:\PythonProjects\test3> & "D:\ProgramData\anaconda3\envs\python311\Scripts\poetry.exe" init

再次使用?&?調用?poetry.exe?執行?init?命令,啟動 Poetry 項目初始化向導。
后續的交互過程如下:

?

This command will guide you through creating your pyproject.toml config.Package name [test3]:  test3
Version [0.1.0]:
Description []:
Author [***** <*****@q q.com>, n to skip]:
License []:
Compatible Python versions [>=3.11]:

Poetry 提示用戶輸入項目相關信息,如包名、版本、描述、作者、許可證以及兼容的 Python 版本。方括號內的值為默認值,用戶直接回車則采用默認值。這里用戶保持大部分默認設置,僅確認了包名為?test3


6.?配置項目依賴

?

Would you like to define your main dependencies interactively? (yes/no) [yes] yesYou can specify a package in the following forms:- A single name (requests): this will search for matches on PyPI- A name and a constraint (requests@^2.23.0)- A git url (git+https://github.com/python-poetry/poetry.git)- A git url with a revision         (git+https://github.com/python-poetry/poetry.git#develop)- A file path (../my-package/my-package.whl)- A directory (../my-package/)- A url (https://example.com/packages/my-package-0.1.0.tar.gz)Package to add or search for (leave blank to skip):Would you like to define your development dependencies interactively? (yes/no) [yes] yes
Package to add or search for (leave blank to skip):

Poetry 詢問用戶是否交互式定義項目的主依賴和開發依賴,并列出了多種添加依賴的方式。用戶兩次選擇?yes?后,均直接回車跳過添加,意味著當前項目暫不添加任何依賴。


7.?確認生成項目配置文件

?

Generated file[project]
name = "test3"
version = "0.1.0"
description = ""
authors = [{name = "*****",email = "*****@q q.com"}
]
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
][build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"Do you confirm generation? (yes/no) [yes] yes

Poetry 展示了根據用戶輸入生成的?pyproject.toml?文件內容,包括項目基本信息、依賴配置和構建系統信息。用戶輸入?yes?確認生成該配置文件,完成項目初始化過程。

總的來說,這段操作通過 PowerShell 在 Conda 環境中使用 Poetry 完成了項目初始化,充分體現了 PowerShell 調用可執行文件的語法特點,以及 Poetry 項目初始化的交互流程。

下一篇預告

CMD 與 PowerShell 中進入 Poetry 虛擬環境的操作方法

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/86308.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/86308.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/86308.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

20242817李臻-安全文件傳輸系統-項目驗收

安全文件傳輸系統項目報告 項目概述 本實驗旨在設計并實現一個完整的安全文件管理系統&#xff0c;基于SM2SM3SM4混合密碼體系&#xff0c;構建了一個具備高安全性的C/S架構文件傳輸平臺。項目采用C/S架構&#xff0c;使用Qt框架開發&#xff0c;滿足Linux系統調用、Socket網…

2025年- H76-Lc184--55.跳躍游戲(貪心)--Java版

1.題目描述 2.思路 只要是在最大覆蓋范圍覆蓋了&#xff0c;就是覆蓋了。 局部最優&#xff1a;每遍歷一個元素取它最大的覆蓋范圍 全局最優&#xff1a;在這個序列里&#xff0c;可以得到最大的覆蓋范圍。如果覆蓋范圍能達到最后一個元素&#xff0c;就是全局最優 &#xff0…

05.查詢表

查詢表 字段顯示可以使用別名: col1 AS alias1, col2 AS alias2, … WHERE子句:指明過濾條件以實現“選擇"的功能: 過濾條件: 布爾型表達式算術操作符:,-,*,/,%比較操作符:,<>(相等或都為空),<>,!(非標準SQL),>,>,<,<范圍查詢: BETWEEN min_num …

Python學習——數組的行列互換

數組的行列互換 data [ [col for col in range (4)] for row in range (4)] for row in data: print (row) print(“--------------”) for r_index,row in enumerate(data): for c_index in range (r_index,len(row)): tmp data [c_index] [r_index] data[c_index] [r_index…

bugku 應急加固1

Linux的應急加固 一、JS劫持 獲取JS劫持域名 JS劫持&#xff0c;JavaScript Hijacking介紹&#xff1a; 攻擊者通過某種方式篡改網頁中的JavaScript代碼&#xff0c;從而使網頁跳轉到惡意域名。 常見攻擊方式有&#xff1a; 中間人攻擊&#xff0c;在網絡傳輸過程中攔截并修…

ant-design4.xx實現數字輸入框; 某些輸入法數字需要連續輸入兩次才顯示

目錄 一、問題 二、解決方法 三、總結 一、問題 1.代碼里有一個基于ant封裝的公共組件數字輸入框&#xff0c;測試突然說 無效了&#xff0c;輸入其他字符也會顯示&#xff1b;改了只有又發現某些 輸入法 需要連續輸入兩次 才能顯示出來。 二、解決方法 1.就離譜&#xff0…

鄭州工程技術學院赴埃文科技開展訪企拓崗促就業活動

6 月 3 日&#xff0c;鄭州工程技術學院信息工程學院&軟件學院黨總支書記尚德基、校企合作處處長吳博、軟件學院院長葉愷、信息工程學院院長馬耀鋒、副院長黃繼海、河南省人工智能產業創新發展聯盟執行秘書長孟松濤等領導一行到訪鄭州埃文科技有限公司。埃文科技總經理助理…

pandas 字符串存儲技術演進:從 object 到 PyArrow 的十年歷程

文章目錄 1. 引言2. 階段1&#xff1a;原始時代&#xff08;pandas 1.0前&#xff09;3. 階段2&#xff1a;Python-backed StringDtype&#xff08;pandas 1.0 - 1.3&#xff09;4. 階段3&#xff1a;PyArrow初次嘗試&#xff08;pandas 1.3 - 2.1&#xff09;5. 階段4&#xf…

[特殊字符] 在 React Native 項目中封裝 App Icon 一鍵設置命令(支持參數與默認路徑)

?? 前置依賴 使用的是社區維護的 CLI 工具: @bam.tech/react-native-make它擴展了 react-native 命令,支持 set-icon 功能。 安裝: yarn add -D "@bam.tech/react-native-make"?? 封裝目標 我們希望能夠通過以下方式調用: # 默認使用 ./icon.png yarn …

[論文閱讀] 人工智能 | 搜索增強LLMs的用戶偏好與性能分析

【論文解讀】Search Arena&#xff1a;搜索增強LLMs的用戶偏好與性能分析 論文信息 作者: Mihran Miroyan, Tsung-Han Wu, Logan King等 標題: Search Arena: Analyzing Search-Augmented LLMs 來源: arXiv preprint arXiv:2506.05334v1, 2025 一、研究背景&#xff1a;…

[2025CVPR]確定性圖像轉換新突破:雙逼近器布朗橋模型(Dual-approx Bridge)技術詳解

本文深入解析CVPR 2024頂會論文《Deterministic Image-to-Image Translation via Denoising Brownian Bridge Models with Dual Approximators》,揭示確定性圖像轉換的核心突破 一、問題背景:確定性圖像轉換的挑戰 在圖像轉換任務中(如超分辨率、醫學影像處理),?確定性…

Python Pytest

1.Pytest用例發現規則 1.1 模塊名(python文件)名必須以 test_ 開頭或 _test 結尾&#xff0c;如 test_case&#xff0c;case_test&#xff0c;下劃線都不能少 1.2 模塊不能放在 . 開頭的隱藏目錄或者叫 venv的目錄下&#xff0c;virtual environment&#xff0c;叫venv1都可以…

CSRF(跨站請求偽造)詳解

目錄 一、&#x1f4d6;什么是CSRF 二、&#x1f517;漏洞利用過程 三、&#x1f4d1;漏洞的前提條件 四、&#x1f50d;常見漏洞發生位置 五、?CSRF挖掘技巧 (一) 抓正常請求包進行初步判斷 (二) Referer 繞過驗證測試 (三) Token 缺失與二次驗證缺失識別 六、??漏…

深入解析 Qwen3-Embedding 的模型融合技術:球面線性插值(Slerp)的應用

在深度學習領域&#xff0c;模型融合技術是一種強大的工具&#xff0c;用于提升模型的魯棒性和泛化能力。通過結合多個模型的優勢&#xff0c;可以減少單一模型的過擬合風險&#xff0c;并在多種任務中實現更優的性能表現。在 Qwen3-Embedding 的訓練過程中&#xff0c;模型融合…

【在線五子棋對戰】二、websocket 服務器搭建

文章目錄 Ⅰ. WebSocket1、簡介2、特點3、原理解析4、報文格式 Ⅱ. WebSocketpp1、認識2、常用接口3、websocketpp庫搭建服務器搭建流程主體框架填充回調函數細節 4、編寫 makefile 文件5、websocket客戶端 Ⅰ. WebSocket 1、簡介 WebSocket 是從 HTML5 開始支持的一種網頁端…

針對異構數據的聯邦學習

在聯邦學習中&#xff0c;數據異構性是指不同客戶端之間的數據分布差異&#xff0c;包括數據的特征空間、標簽空間以及數據量等方面的差異。處理異構數據是聯邦學習中的一個重要挑戰&#xff0c;因為異構數據可能導致模型訓練過程中的性能不穩定、收斂速度較慢&#xff0c;甚至…

【判斷自整除數】2022-4-6

緣由是判斷自整除數的&#xff0c;這個我的結果是正確的&#xff0c;但是提交就有運行錯誤是怎么回事啊-編程語言-CSDN問答 void 自整除數字() {//所謂的自整除數字就是該數字可以整除其每一個位上的數字。 //對一個整數n,如果其各個位數的數字相加得到的數m能整除n,則稱n為自…

@Import原理與實戰

文章目錄 前言一、導入普通類二、導入ImportSelector實現類三、導入ImportBeanDefinitionRegistrar實現類四、Import注解的解析4.1、解析實現ImportSelector的候選bean4.2、解析實現ImportBeanDefinitionRegistrar的候選bean4.3、DeferredImportSelector的特殊處理 總結 前言 I…

day 18進行聚類,進而推斷出每個簇的實際含義

浙大疏錦行 對聚類的結果根據具體的特征進行解釋&#xff0c;進而推斷出每個簇的實際含義 兩種思路&#xff1a; 你最開始聚類的時候&#xff0c;就選擇了你想最后用來確定簇含義的特征&#xff0c; 最開始用全部特征來聚類&#xff0c;把其余特征作為 x&#xff0c;聚類得到…

Java并發編程實戰 Day 11:并發設計模式

【Java并發編程實戰 Day 11】并發設計模式 開篇 這是"Java并發編程實戰"系列的第11天&#xff0c;今天我們聚焦于并發設計模式。并發設計模式是解決多線程環境下常見問題的經典解決方案&#xff0c;它們不僅提供了優雅的設計思路&#xff0c;還能顯著提升系統的性能…