标签: requirements.txt

如何在本地文件系统上为tarball创建pip需求文件?

告诉我,如果我正在尝试做的事情没有意义.

我想创建一个虚拟环境,其中包括MySQLDb 1.2.3.该库作为gzipped tarball(.tgz)文件分发.我想在requirements/apps.txt中的需求文件中安装所有内容 - 包括我本地文件系统上的tarball - 这是基于我在http://thraxil.org/users/anders/posts/2009/06中看到的设置/ 12/Django-Deployment-with-virtualenv-and-pip /):

pip.py install -E ve --enable-site-packages --requirement requirements/apps.txt
Run Code Online (Sandbox Code Playgroud)

我找不到关于本地文件的pip要求文件格式的任何文档.

apps.txt如果目录requirements/包含文件,需要file()需要包含MySQL-python-1.2.3.tgz什么?

python pip virtualenv requirements.txt

7
推荐指数
1
解决办法
2940
查看次数

我应该在模块的requirements.txt中包含Sphinx和/或Nose吗?

我在Github上创建了一个Python模块,它使用Nose进行单元测试,使用Sphinx生成文档.我有两个问题:

  • 我应该在我的模块的setup.py(install_requires)依赖项中包含Sphinx和/或Nose,因为它们不是基本模块功能所必需的,只有你想自己构建文档/运行测试?

  • 我是否应该在Github上的模块的requirements.txt中包含Sphinx和/或Nose,原因相同但是从Github下载我的项目的用户可能更有可能构建docs/run测试?

这是我的第一个Python模块,因此我们将非常感谢您提供一些最佳实践/标准建议.

python standards pip setup.py requirements.txt

7
推荐指数
1
解决办法
1023
查看次数

有没有办法在我自己的python项目中自动检测所需的模块和包

我想创建一个python分发包,并且需要检查我自己的包所需的所有包。

对于requirements.txt,它包括它需要的所有包。但是,我想找到一种方法来检查我需要的所有包,并且对于某些包,它们也是我项目中其他包的一些要求。

有什么方法可以检查我需要哪些包,并为我自己的项目维护最少的包?

python pip requirements.txt

7
推荐指数
2
解决办法
3261
查看次数

如何使用pip requirements.txt文件安装python模块附加组件

PIP requirements.txt文件称,演员可以用线等安装

MyPackage==3.0 [PDF]
Run Code Online (Sandbox Code Playgroud)

所以在我的requirements.txt文件中,我有一行内容如下:

requests==2.9.1 [security]
Run Code Online (Sandbox Code Playgroud)

但是,当我运行命令时,不是为请求模块安装安全附加功能:

pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,提示我的文件格式不正确:

Invalid requirement: 'requests==2.9.1 [security]'
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 77, in __init__
    req = pkg_resources.Requirement.parse(req)
  File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3036, in parse
    req, = parse_requirements(s)
  File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2980, in parse_requirements
    "version spec")
  File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2956, in scan_list
    raise RequirementParseError(msg, line, "at", line[p:])
RequirementParseError: Expected ',' or end-of-list in requests==2.9.1 [security] at  [security]
Run Code Online (Sandbox Code Playgroud)

有谁知道我可能做错了什么?

python pip requirements.txt

7
推荐指数
1
解决办法
7014
查看次数


将需求从requirements.txt添加到conda meta.yaml

我正在编写一个 Python 包,我想在 pypi 和 conda 上发布。为了避免错误,我想将需求存储在一个文件中;至少在可预见的未来,它们是一样的。

从meta.yaml 到setup.py 很容易(例如通过pyyaml),但是反过来呢?如何将需求注入到meta.yaml中?

有没有类似的东西:

{% set data = load_setup_py_data() %}
...
requirements:
  run:
    {{ data.get('install_requires') }}
Run Code Online (Sandbox Code Playgroud)

这种情况的最佳实践是什么?

python dependencies pypi requirements.txt anaconda

7
推荐指数
1
解决办法
1138
查看次数

Pipreqs requirements.txt is not correct

您好,我在使用 Python 库时遇到问题pipreqs。它不会生成正确的requirements.txt文件。我正在使用 Python 虚拟环境,我安装的唯一软件包是pipreqsselenium

pip install pipreqs
pip install selenium
Run Code Online (Sandbox Code Playgroud)

项目结构:

MyProject
 |- test.py
Run Code Online (Sandbox Code Playgroud)

并且test.py只有一行:

pip install pipreqs
pip install selenium
Run Code Online (Sandbox Code Playgroud)

首先当我这样做的时候

pipreqs ./
Run Code Online (Sandbox Code Playgroud)

我遇到了错误UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3474: character maps to <undefined> ,我设法通过使用解决了

pipreqs ./ --encoding=utf-8
Run Code Online (Sandbox Code Playgroud)

但现在requirements.txt生成的结果与我的期望不符。在我看来,它应该等于:

selenium==1.341.0
Run Code Online (Sandbox Code Playgroud)

但它等于:

brotli==1.0.9
cryptography==3.2.1
ipaddr==2.2.0
lxml==4.6.1
mock==4.0.2
ordereddict==1.1
protobuf==3.13.0
pyOpenSSL==19.1.0
simplejson==3.17.2
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试克隆此代码并执行它时,pip install -r requirements.txt它不会安装selenium,并且代码不会运行。

这里发生了什么事?

python package requirements.txt

7
推荐指数
1
解决办法
1万
查看次数

如何检查Python项目中是否使用了requirements.txt文件中列出的所有包

我有一个包含所有已安装软件包的需求文件。在项目的大规模重构过程之后,不再需要列出的一些包。问题是我不确定是哪一个。有没有办法确定requirements.txt文件中列出的哪些包在代码中实际使用?

python python-3.x requirements.txt

7
推荐指数
2
解决办法
5924
查看次数

使用Poetry导出requirements.txt时如何省略依赖

我有一个 Python3 Poetry 项目,其中有一个pyproject.toml指定依赖项的文件:

[tool.poetry.dependencies]
python = "^3.10"
nltk = "^3.7"
numpy = "^1.23.4"
scipy = "^1.9.3"
scikit-learn = "^1.1.3"
joblib = "^1.2.0"

[tool.poetry.dev-dependencies]
pytest = "^5.2"
Run Code Online (Sandbox Code Playgroud)

requirements.txt使用命令将这些依赖项导出到文件中poetry export --without-hashes -f requirements.txt --output requirements.txt,生成以下文件requirements.txt

click==8.1.3 ; python_version >= "3.10" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
joblib==1.2.0 ; python_version >= "3.10" and python_version < "4.0"
nltk==3.8.1 ; python_version >= "3.10" and python_version …
Run Code Online (Sandbox Code Playgroud)

python pip requirements.txt python-poetry

7
推荐指数
1
解决办法
6513
查看次数

如何在“requirements.txt”中包含发布候选版本 (rc) 或发布后的实际版本

我想在我的requirements.txtfor中设置依赖项tensorflow~=2.5.0。截至撰写本文时,tensorflow==2.5.0尚未发布。可用的最新版本是候选版本tensorflow==2.5.0rc3。我如何简洁地告诉pip“安装最新的tensorflow2.5.x 版本,包括候选版本”?

到目前为止我尝试过的:

  • tensorflow~=2.5.0
ERROR: Could not find a version that satisfies the requirement tensorflow~=2.5.0 (from versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3)
ERROR: No matching distribution found for tensorflow~=2.5.0
Run Code Online (Sandbox Code Playgroud)
  • tensorflow>2.4.1
ERROR: Could not find a version that satisfies the requirement tensorflow>2.4.1 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 1.15.0rc0, 1.15.0rc1, 1.15.0rc2, 1.15.0rc3, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 1.15.5, 2.0.0a0, 2.0.0b0, 2.0.0b1, 2.0.0rc0, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, …
Run Code Online (Sandbox Code Playgroud)

python pip requirements.txt

6
推荐指数
1
解决办法
2415
查看次数