Windows下多版本Python共享Poetry測(cè)試安裝
前言
技術(shù)棧
Windows 10
Python 3.8.10
Python 3.11.2
pip 23.0.1
pipx 1.2.0
poetry 1.4.1
Python 3.8 安裝目錄
C:\Python38
Python 3.11 安裝目錄
C:\Python311
安裝 poetry
設(shè)置將以下路徑加入 path 環(huán)境變量
C:\Python38 C:\Python38\Scripts C:\Python311 C:\Python311\Scripts C:\Users\qbit\.local\bin\
復(fù)制文件
C:\Python38\python.exe -> C:\Python38\py38.exe C:\Python311\python.exe -> C:\Python38\py311.exe
設(shè)置 pip 國內(nèi)鏡像源
py38 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ py311 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
升級(jí) pip
py38 -m pip install pip --upgrade py311 -m pip install pip --upgrade
安裝或升級(jí) pipx
py38 -m pip install pipx --upgrade py311 -m pip install pipx --upgrade
在 Python 3.11 下用 pipx 安裝 Poetry
py311 -m pipx install poetry --force -i https://mirrors.aliyun.com/pypi/simple/
查看安裝情況
> where poetry c:\Users\qbit\.local\bin\poetry.exe > poetry --version Poetry (version 1.4.1)
修改 potry 緩存目錄
poetry config cache-dir D:\pypoetry
設(shè)置將虛擬環(huán)境目錄放在項(xiàng)目?jī)?nèi)
poetry config virtualenvs.in-project true
測(cè)試多版本共享
測(cè)試 Python 3.11
創(chuàng)建空目錄 F:\tmp\test311,在里面創(chuàng)建文件 pyproject.toml,文件內(nèi)容如下:
[tool.poetry] name = "test" version = "0.1.0" description = "" authors = ["qbit"] readme = "README.md" [[tool.poetry.source]] name = "aliyun" url = "https://mirrors.aliyun.com/pypi/simple/" default = true [tool.poetry.dependencies] python = "^3.11" requests = "~2.28.2" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"
創(chuàng)建虛擬環(huán)境并安裝第三方庫
poetry update -vv
查看虛擬環(huán)境信息
> poetry env info Virtualenv Python: 3.11.2 Implementation: CPython Path: F:\tmp\test311\.venv Executable: F:\tmp\test311\.venv\Scripts\python.exe Valid: True System Platform: win32 OS: nt Python: 3.11.2 Path: C:\Python311 Executable: C:\Python311\python.exe
測(cè)試 Python 3.8
創(chuàng)建空目錄 F:\tmp\test38,在里面創(chuàng)建文件 pyproject.toml,文件內(nèi)容如下:
[tool.poetry] name = "test" version = "0.1.0" description = "" authors = ["qbit"] readme = "README.md" [[tool.poetry.source]] name = "aliyun" url = "https://mirrors.aliyun.com/pypi/simple/" default = true [tool.poetry.dependencies] python = "^3.8" requests = "~2.28.2" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"
切換 python 版本并創(chuàng)建虛擬環(huán)境
poetry env use C:\Python38\python.exe
查看虛擬環(huán)境信息
> poetry env info Virtualenv Python: 3.8.10 Implementation: CPython Path: F:\tmp\test38\.venv Executable: F:\tmp\test38\.venv\Scripts\python.exe Valid: True System Platform: win32 OS: nt Python: 3.8.10 Path: C:\Python38 Executable: C:\Python38\python.exe
安裝第三方庫
poetry update -vv
后記
如果報(bào)類似如下錯(cuò)誤,部分包安裝不成功,可以 poetry shell 進(jìn)入虛擬環(huán)境后用 pip 安裝報(bào)錯(cuò)的包
_WheelFileValidationError
version.py is not mentioned in RECORD
In {self._zipfile.filename}, hash / size of {item.filename} didn't match RECORD出現(xiàn)上面這個(gè)錯(cuò)誤的原因是第三方包不夠規(guī)范,使得 poetry 在校驗(yàn)的時(shí)候出錯(cuò)。
可以參考
installer: do not fail on invalid wheels
以上就是Windows下多版本Python共享Poetry測(cè)試安裝的詳細(xì)內(nèi)容,更多關(guān)于Windows多版本Python共享Poetry的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
python實(shí)現(xiàn)將內(nèi)容分行輸出
本文給大家分享的是使用python實(shí)現(xiàn)將一行里的內(nèi)容進(jìn)行分行輸出,一共給出了四種方法,小伙伴們可以參考下2015-11-11
python 讀入多行數(shù)據(jù)的實(shí)例
下面小編就為大家分享一篇python 讀入多行數(shù)據(jù)的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-04-04
如何在Django項(xiàng)目中引入靜態(tài)文件
這篇文章主要介紹了如何在Django項(xiàng)目中引入靜態(tài)文件,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-07-07
Python無法安裝包的一種解決(Requirement already satisfied問題)
這篇文章主要介紹了Python無法安裝包的一種解決(Requirement already satisfied問題),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-08-08
Python Tkinter創(chuàng)建GUI應(yīng)用程序的示例
Tkinter提供了豐富的功能和靈活的接口,讓開發(fā)者能夠輕松地構(gòu)建出各種各樣的圖形用戶界面,本文介紹了使用Python的Tkinter庫創(chuàng)建圖形用戶界面GUI應(yīng)用程序,感興趣的可以了解一下2024-12-12

