我尝试通过运行以下命令从 Artifactory 安装一个软件包
pip install package_name -i http://artifactory.XYZ.com/artifactory/api/pypi/XYZ-py-local/simple --trusted-host artifactory.XYZ.com
Run Code Online (Sandbox Code Playgroud)
该包下载正常。然而,当涉及到查找依赖项时,它会抛出异常,因为我在 Artifactory 中没有 PyPI 远程存储库。
是否可以将 pip 指向 PyPI 以获得特定依赖项?
我使用 apyproject.toml来存储需求,因为我使用诗歌顶部处理依赖项并构建包。
运行以下
poetry shell
Run Code Online (Sandbox Code Playgroud)
返回以下错误
/home/harshagoli/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
"program uses threads.", RuntimeWarning)
The currently activated Python version 2.7.17 is not supported by the project (^3.7).
Trying to find and use a compatible version.
Using python3 (3.7.5)
Virtual environment already activated: /home/harshagoli/.cache/pypoetry/virtualenvs/my-project-0wt3KWFj-py3.7
Run Code Online (Sandbox Code Playgroud)
我怎样才能克服这个错误?为什么这个命令不起作用?
我正在使用一个名为Poetry 的全新 Python 包管理器。
它在创建新项目(环境)时创建了几个文件/目录,但我不确定我应该添加哪个以.gitignore获得最佳实践。
假设我通过这样做创建了一个新的诗歌项目:
$ poetry new foo_project
$ cd foo_project
$ poetry add numpy
$ ls
Run Code Online (Sandbox Code Playgroud)
有:
tests (directory)
foo_project (also a directory)
pyproject.toml (a file that specifies installed packages)
poetry.lock (a lock file of installed packages)
README.rst (I don't know why README is created but it just shows up.)
Run Code Online (Sandbox Code Playgroud)
我通常添加tests/, foo_project/,poetry.lock并且README.rst因为它们似乎依赖于创建项目的机器。另外,我似乎只能用 来重现环境,pyproject.toml所以这是我忽略所有其他文件/目录的另一个原因。
然而,这只是我的预感,不幸的是,我找不到任何官方指南,我真的应该.gitignore在官方文档中添加什么。
它只是让我感到烦恼,我不确定我在做什么。我应该将哪些添加到我的.gitignore?
我的项目中有一个文件,出于性能原因,我想对其进行编译:
mylibrary/myfile.py
如何用 Poetry 实现这一目标?
我正在使用poetry版本 1.1.6 来构建我的项目并将其发布到内部工件。
我提供了以下命令并配置了存储库。
poetry config repositories.myrepo https://my-internal-artifactory/api/pypi/python/simple
Run Code Online (Sandbox Code Playgroud)
如何为内部存储库配置 API 令牌?
我试过这个
poetry config http-basic.myrepo mytoken
Run Code Online (Sandbox Code Playgroud)
假设我提供了用户名和密码,它仍然提示输入密码。然而,我所拥有的只是一个令牌。我没有用户名和密码。
该文档似乎没有为使用令牌的私有存储库提供足够的信息,
注意:在诗歌之前,我们使用curl 使用令牌上传到artificialory。
我们如何使用诗歌中的令牌发布到私人存储库?有可能做到这一点吗?任何帮助将不胜感激。
我使用 Python Poetry 并需要自动化该过程。具体来说,每次我需要进入一个目录
cd /work/directory
Run Code Online (Sandbox Code Playgroud)
并生成一个诗歌外壳
poetry shell
Run Code Online (Sandbox Code Playgroud)
并再次转到另一个目录
cd /other/directory
Run Code Online (Sandbox Code Playgroud)
完成工作。
我很想用一个小脚本来自动执行此操作,例如
#!/bin/bash
cd /work/directory
poetry shell
cd /other/directory
# do work
Run Code Online (Sandbox Code Playgroud)
然而,每当我运行这个脚本时,我就会卡在poetry shell. 有没有像 bash 这样的选项,-c以便我可以执行以下操作?
poetry shell -c "cd /other/directory && do work"
Run Code Online (Sandbox Code Playgroud) 我想从poetry.lock文件安装包;使用poetry install。
然而,大多数包都会抛出完全相同的错误,这表明存在共同的基本问题。
\n是什么原因造成的?标准修复是什么?
\n规格:
\n终端:
\nrm poetry.lockpoetry updatepoetry installme@PF2DCSXD:/mnt/c/Users/user/Documents/GitHub/workers-python/workers/composite_key$ poetry update\nUpdating dependencies\nResolving dependencies... (217.2s)\n\nWriting lock file\n\nPackage operations: 55 installs, 8 updates, 0 removals\n\n \xe2\x80\xa2 Updating pyparsing (3.0.4 -> 2.4.7)\n \xe2\x80\xa2 Updating pyyaml (5.4.1 -> 6.0)\n \xe2\x80\xa2 Installing arrow (1.2.1)\n \xe2\x80\xa2 Installing chardet (4.0.0)\n \xe2\x80\xa2 …Run Code Online (Sandbox Code Playgroud) 当尝试使用 Poetry 安装 Python 依赖项时,出现以下错误:
$ poetry install
The currently activated Python version 2.7.15 is not supported by the project (>=3.6).
Trying to find and use a compatible version.
Using python3 (3.7.4)
Skipping virtualenv creation, as specified in config file.
Updating dependencies
Resolving dependencies... (1.7s)
[SolverProblemError]
The current project's Python requirement (>=3.6) is not compatible with some of the required packages Python requirement:
- pre-commit requires Python >=3.6.1
Because no versions of pre-commit match >2.2.0,<3.0.0
and pre-commit (2.2.0) requires Python …Run Code Online (Sandbox Code Playgroud) 我最近开始尝试使用 Poetry 进行包和依赖管理,并且我仍在适应它与我使用 setuptools 的经验之间的差异。具体来说,我希望能帮助您理解如何处理以下场景。
我有一个数据文件,我想将其与存储在包子目录中的包捆绑在一起。使用 setup.py,我将在 setup.py 文件中指定文件和目录名称,然后使用 pkg_resources API 访问代码中的文件。
使用 Poetry 和 pyproject.toml 的等效方法是什么?
诗歌无法完成任何install或add不抛出EnvCommandError与无法找到一个setup.py“for”有关的事情soupsieve。
它查找版本“2020.12.21.3-lambda”,我不明白为什么它没有像其他依赖项一样使用普通版本从远程源加载依赖项。
\n$ poetry update\nUpdating dependencies\nResolving dependencies... (54.1s)\n\nWriting lock file\n\nPackage operations: 59 installs, 0 updates, 0 removals\n\n \xe2\x80\xa2 Installing soupsieve (2020.12.21.3-lambda): Failed\n\n EnvCommandError\n\n Command ['/home/git/my-project/.venv/bin/pip', 'install', '--no-deps', 'file:///home/Library/Caches/pypoetry/artifacts/22/36/ca/c8aae41f80011be881aa337cc80abc25ffd8542471c325e4410afa86c8/authorities-deployer-2020.12.21.3-lambda.zip'] errored with the following return code 1, and output: \n Looking in indexes: ... # censored proxy\n Processing /home/Library/Caches/pypoetry/artifacts/22/36/ca/c8aae41f80011be881aa337cc80abc25ffd8542471c325e4410afa86c8/authorities-deployer-2020.12.21.3-lambda.zip\n ERROR: Command errored out with exit status 1:\n command: /home/git/my-package/my-package/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/q6/xjd92kc90zsds149_rx08cy40000gp/T/pip-req-build-40kngare/setup.py'"'"'; __file__='"'"'/private/var/folders/q6/xjd92kc90zsds149_rx08cy40000gp/T/pip-req-build-40kngare/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\\r\\n'"'"', …Run Code Online (Sandbox Code Playgroud) python-poetry ×10
python ×6
python-3.x ×3
artifactory ×2
pip ×2
cython ×1
gitignore ×1
linux ×1