标签: requirements.txt

Python Django requirements.txt

我有一个requirements.txt包含所有依赖项的文件,但未正确处理:

一段时间后pip install -r requirements.txt,我得到以下内容pip freeze:

argparse==1.2.1
wsgiref==0.1.2
Run Code Online (Sandbox Code Playgroud)

但是当我做一个pip安装:

numpy==1.6.2
Django==1.4.2
django-tastypie==0.9.14
pyes==0.19.1
Run Code Online (Sandbox Code Playgroud)

然后运行我的pip install -r requirements.txt.然后它工作.

这是我的requirements.txt包含:

numpy==1.6.2
Django==1.4.2
django-tastypie==0.9.14
urllib3==1.5
pyes==0.19.1
BeautifulSoup==3.2.1
MySQL-python==1.2.3
IMAPClient==0.9.1
Jinja2==2.6
Pillow==2.0.0
amqp==1.0.9
anyjson==0.3.3
billiard==2.7.3.22
celery==3.0.16
django-celery==3.0.11
django-compressor==1.3
django-concurrency
django-extensions==1.1.1
https://codeload.github.com/toastdriven/django-haystack/zip/master#egg=django-haystack
django-model-utils==1.2.0
django-multiforloop==0.2.1
django-social-auth==0.7.22
html5lib==0.95
httplib2==0.8
kombu==2.5.7
logilab-astng==0.24.2
logilab-common==0.59.0
oauth2==1.5.211
ordereddict==1.1
pycrypto==2.6
pylint==0.27.0
python-dateutil==1.5
python-openid==2.2.5
pytz==2013b
six==1.3.0
unittest2==0.5.1
wsgiref==0.1.2
xlrd==0.9.0
xmltodict==0.4.6
django-storages>=1.1.8
boto==2.8.0
lxml==3.1.0
pyelasticsearch==0.4.1
django-tastypie-elasticsearch==0.1.0
Run Code Online (Sandbox Code Playgroud)

有人会有解决方案吗?

python django pip requirements.txt

12
推荐指数
2
解决办法
4万
查看次数

安装新软件包时如何自动更新需求文件?

通过跟踪虚拟环境的需求pip freeze非常简单。

pip freeze > requirements.txt
Run Code Online (Sandbox Code Playgroud)

然而,目前,每当新包添加到venv,都需要手动将其添加到需求文件中。为此,我通常只是再次运行 freeze 命令并将其通过管道传输到需求文件中,但有时我忘记运行此命令,这可能会很麻烦,尤其是在跨不同位置的存储库中,每当我必须记住需要哪些包时安装!

每当在虚拟环境中安装新软件包时,是否有任何方法可以自动更新文件 requirements.txt 以包含这个新软件包?

pip requirements.txt virtual-environment

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

没有名为 pipreqs.__main__ 的模块;'pipreqs' 是一个包,不能直接执行

我正在尝试使用 pipreqs 模块生成需求文本。但 pipreqs 正在生成以下错误。

No module named pipreqs.__main__; 'pipreqs' is a package and cannot be directly executed
Run Code Online (Sandbox Code Playgroud)

我正在使用 Visual Studio Code,并尝试通过在终端中执行以下命令来使用 pipreqs。

python -m pipreqs [location/project]
Run Code Online (Sandbox Code Playgroud)

我已经安装了 pipreqs 并更新了 pip。但问题仍然存在。这是一个错误还是我以错误的方式进行了操作?

python python-module requirements.txt visual-studio-code

12
推荐指数
1
解决办法
7734
查看次数

通过需求文件从 pip 安静输出?

pip 有一个 -q/--quiet 标志,可以从命令行理想地工作。我正在使用自动部署过程 (Amazon Elastic Beanstalk),并且这些工具使用 pip 从需求文件进行安装。

不幸的是,pip 正在生成非错误输出,由于其记录器无法处理非 ASCII 输出,导致 EB 中止。

由于我无法将安静标志直接应用于 pip 命令(它会自动运行),是否可以在我的需求文件或环境变量中设置一个每行标志来抑制 pip 的输出?

pip requirements.txt amazon-elastic-beanstalk

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

setup.py&pip:覆盖requirements.txt中依赖项的子依赖项之一

我正在开发一个软件包,在我的工作中requirements.txt,我有一个依赖:wikipedia.现在,wikipedia1.3使用requests-2.2.1我的包使用版本2.3.0.

此外,正如人们所预料的那样,wikipedia-1.3安装取决于它的依赖性.

但是,如果我开始一个新的virtualenv和直接包括wikipedia在我的requirements.txt,它提供了一个ImportErrorrequests,因为当时的setup.py运行,requests-2.3.0setup.py不执行,除非所有其他执行.在下面附的图,有没有运行setup.pyrequests它就会被解开了.

请求已安装但未同时运行setup.py

出于某种奇怪的原因,wikipediasetup.py包含import wikipedia,这反过来进口它的依赖他们甚至在安装之前; 然而,它通过了CI测试,因为它通过pip单独安装需求然后运行setup.py.

为了解决这个问题,我制作了一个包含以下内容的安装脚本:

pip install -r requirements.txt
pip install wikipedia
pip install -e .
Run Code Online (Sandbox Code Playgroud)
  • 这安装requests-2.3.0beautifulsoup4;
  • 然后安装wikipedia(其然后可以运行setup.py并安装wikipediarequests-2.2.1)
  • 然后'pip install -e.' 选项requests-2.3.0再次安装我的包.

因此requests-2.3.0首先安装,然后由旧版本2.2.1替换,然后再次替换2.3.0. …

python pip setup.py python-2.7 requirements.txt

11
推荐指数
1
解决办法
2450
查看次数

在TravisCI上缓存pipenv/Pipfile依赖项

关于缓存的Travis 文档没有具体提到如何缓存从pipenv的Pipfile安装的python依赖项,而不是pip通常的requirements.txt.我尝试设置每个文档的pip缓存,但是构建时间根本没有改进,我看​​到pipenv在每次运行时安装它的deps.

这是我目前使用的语法 - 正确的语法是什么?(或甚至支持?)

language: python
python:
  - "3.6"

cache: pip

cache:
    directories:
        - proj/static/node_modules
        - $HOME/.cache/pip
Run Code Online (Sandbox Code Playgroud)

python caching travis-ci requirements.txt pipenv

11
推荐指数
1
解决办法
1208
查看次数

pip install via requests.txt 指定直接 GitHub 私有存储库 + 分支名称,错误退出状态 128

我正在尝试将一个包添加到我的requirements.txt文件中,即:

  • 来自私人 GitHub 存储库
    • 我是私人回购的成员
    • 我已经ssh配置了私人仓库
  • 来自 之外的一个分支master,其名称中带有斜杠
  • 使用ssh协议

互联网上到处都是关于这个话题的问题。以下是关于此的pip文档

pip install -e "vcs+protocol://repo_url/#egg=pkg&subdirectory=pkg_dir"

以及来自如何在requirements.txt中声明直接github源的GitHub答案

git+git://github.com/path/to/package-two@master#egg=package-two


尝试方法#1

我试图在我的requirements.txt文件中使用这个答案:

-e git+ssh://github.com/Organization/repo-name.git@branch/name#egg=foo
Run Code Online (Sandbox Code Playgroud)

我收到错误:

ERROR: Command errored out with exit status 128: git clone -q ssh://github.com/Organization/repo-name.git /path/to/venv/src/foo Check the logs for full command output.
Run Code Online (Sandbox Code Playgroud)

当我使用以下选项查看日志时--log

-e git+ssh://github.com/Organization/repo-name.git@branch/name#egg=foo
Run Code Online (Sandbox Code Playgroud)

尝试方法#2

我尝试的另一种方法requirements.txt

-e git+git@github.com:Organization/repo-name.git#egg=foo
Run Code Online (Sandbox Code Playgroud)

这里面的克隆确实有效!它还打印此警告:DEPRECATION: This form of VCS requirement is being deprecated

不幸的是,我无法弄清楚如何以这种格式指定分支名称。


我究竟做错了什么?我错过了什么吗?

仅供参考,我的版本:

ERROR: …
Run Code Online (Sandbox Code Playgroud)

python git pip github requirements.txt

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

PyCharm 将所有 txt 文件视为需求文件

我的项目中有requirements.txt 文件,PyCharm 可以完美地使用它。但是,它还会检查所有其他 txt 文件并显示误导性的错误消息。例如,拥有带有字符串的 foo.txt 文件

bar baz
Run Code Online (Sandbox Code Playgroud)

写入其中会产生以下消息:

<versionspec>, RequirementsTokenType.COMMENT, RequirementsTokenType.EOL, RequirementsTokenType.LSBRACE, RequirementsTokenType.SEMICOLON or RequirementsTokenType.WHITE_SPACE expected, got 'baz'
Run Code Online (Sandbox Code Playgroud)

我绝对不希望 PyCharm 将所有 txt 文件视为需求文件,我该如何改变这种奇怪的行为?

PyCharm 2020.2.1 CE

python pycharm requirements.txt

11
推荐指数
1
解决办法
1497
查看次数

Github Actions下构建作业时如何安装本地python包?

我正在构建一个 python 项目—— potion. 我想在将新分支合并到 master 之前使用 Github 操作来自动执行一些 linting 和测试。

为此,我使用了对 Github 推荐的 python actions 启动工作流程——Python Application的轻微修改。

在作业中的“安装依赖项”步骤中,我收到错误。这是因为 pip 尝试安装我的本地软件包potion但失败。

失败的代码if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

对应的错误是:

ERROR: git+https@github.com:<github_username>/potion.git@82210990ac6190306ab1183d5e5b9962545f7714#egg=potion is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp, bzr+lp, bzr+file, git+http, git+https, git+ssh, git+git, git+file, hg+file, hg+http, hg+https, hg+ssh, hg+static-http, svn+ssh, …
Run Code Online (Sandbox Code Playgroud)

python pip github requirements.txt github-actions

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

在 Jenkins 中:使用 SSH 密钥从 git repo 安装 pip

在我的 Jenkins 工作中,在构建阶段,我执行pip install -r requirements.txt. 在我的项目要求中,有一些通往私有 git 存储库的路径,需要 SSH 密钥进行身份验证。我已经创建了密钥(无密码),将公钥添加到 BitBucket 服务器,将私钥添加到 Jenkins 的凭据。

我的项目的代码与那些相同的SSH密钥(内部,詹金斯使用GIT_SSH)成功扳回一,但PIP不知道它们传递到服务器进行身份验证(日志显示:Permission denied (publickey)

我已经看到Use SSH Key from Jenkins Git Plugin to Run Git Commands during Build,但没有回答。我也看过其他一些关于Publish Over SSH插件的讨论,但我不确定它是否适用于我..

顺便说一下,构建机器是 Windows。

自动将私钥写入<home_folder>\.ssh\id_rsa对我来说似乎存在安全风险,尽管我可能错了..?

有没有办法将 Jenkins 配置为使用与 pip install ssh 条目相同的 SSH 密钥?

git ssh pip jenkins requirements.txt

10
推荐指数
1
解决办法
702
查看次数