簡體   English   中英

使用 pipenv 安裝時如何忽略特定包的依賴關系?

[英]How to ignore the dependencies of a specific package when installing it with pipenv?

是否有可能在不安裝依賴項的情況下使用 pipenv 安裝 python 包?

我正在為Pipfile尋找pip install package_name --no-dependencies的類似物。 我已經嘗試使用標記進行指定,但它引發了異常。

[packages]
"psycopg2-binary" = "*"
"aiopg"={version = "*", markers="--no-dependencies"}

盡管問題不是很清楚,但您可以使用一些技巧。

比如,首先使用普通的pipenv install <pkg-name><\/code>安裝包
然后在安裝軟件包后,只需將其從Pipfile<\/code>中刪除,然后使用pipenv lock<\/code>文件

另一個選項可以是在 dev-dependencies 中安裝\/移動包
pipenv install --dev <pkg-name><\/code>
這只會在本地環境中安裝軟件包,而不是在部署中。

或... 使用pip install ...<\/code>

我不確定 pipenv 是否支持,但我認為以下選項可能有效(從未嘗試過):

  1. 通過 pip 安裝到 requirements.txt 文件中

    pip install <package> --no-deps -r requirements.txt --> 然后導入到 pipenv pipenv install -r /path/to/requirements.txt

  2. 如果當前項目中已有 Pipfile,請將當前 pipenv 文件導出到 requirements.txt 文件

    pipenv lock -r > requirements.txt

  3. 合並這兩個文件,然后從合並的 requirements.txt 文件中安裝 pipenv

    pipenv install -r path/to/requirements.txt

也許文檔中的此鏈接也可能有所幫助

目前, pipenv不支持這個。 一種解決方法是在Pipfile的末尾添加如下script

[scripts]
install  = "sh -c 'pipenv install ; pip install --no-deps aiopg'"

使用此腳本,調用pipenv run install會安裝[packages]部分中的所有依賴項,包括aiopg但不包括其依賴項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM