“无法从安装目录获取安装脚本的一致路径”
我正在使用 pip 从 git 存储库安装包:
pip install -e git+git://github.com/knipknap/SpiffWorkflow.git@master#egg=SpiffWorkflow-dev
存储库被毫无问题地克隆,但安装失败并显示以下消息:
Running setup.py egg_info for package SpiffWorkflow
Installing collected packages: SpiffWorkflow
Running setup.py develop for SpiffWorkflow
error: ("Can't get a consistent path to setup script from installation
directory", '/', '/home/fcorreia/venvs/myproj/src/spiffworkflow')
我尝试查看该项目的 setup.py,但没有取得多大成功......有什么想法吗?
I'm using pip to install a package from a git repository:
pip install -e git+git://github.com/knipknap/SpiffWorkflow.git@master#egg=SpiffWorkflow-dev
The repo gets cloned without a problem, but installation fails with this message:
Running setup.py egg_info for package SpiffWorkflow
Installing collected packages: SpiffWorkflow
Running setup.py develop for SpiffWorkflow
error: ("Can't get a consistent path to setup script from installation
directory", '/', '/home/fcorreia/venvs/myproj/src/spiffworkflow')
I have tried taking a look to the project's setup.py, but without much success... Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
对于未来的人来说,如果您在 Windows 10 上使用旧版本的 setuptools 并且看起来有一个额外的斜杠,您需要更新 python 包“setuptools”来解决这个问题 windows 10 python bug
您可以通过多种方式更新,但其中一种是
python -m pip install --upgrade安装工具
For future folk, if you're using an older version of setuptools on windows 10 and it looks like it has an extra slash, you need to update the python package 'setuptools' to get around this windows 10 python bug
you can update any number of ways, but one is
python -m pip install --upgrade setuptools
您的包中需要有一个 pyproject.toml 文件。我不知道为什么这会使错误消失,但它确实有效。此文件是 PEP 518“指定 Python 项目的最低构建系统要求”的一部分。
如果您的项目中有 pyproject.toml ,您可以将包放在 src 子文件夹中:
我不知道为什么会这样,但它会使错误消息消失当您运行
pip install -e .
以“可编辑”模式安装软件包时。该文件甚至不需要包含任何内容,它可以是一个空白文件,错误就会消失。(为了弄清楚这一点,我发现了一个工作项目,其包存储在
src
文件夹下,并不断删除内容,直到出现该错误。这显然是 Pip 中的一些错误。我的版本是 18.1我的机器上运行的是 Windows 10 for Python 3.7。)You need to have a
pyproject.toml
file in your package. I have no idea why this makes the error go away, but it works. This file is part of PEP 518 "Specifying Minimum Build System Requirements for Python Projects".You can have your package in a
src
subfolder if you have apyproject.toml
in your project:I have no idea why this works, but it makes the error message go away when you run
pip install -e .
to install the package in "editable" mode. The file doesn't even have to have anything in it, it can be a blank file and the error goes away.(To figure this out, I found a working project that had its package stored under a
src
folder and kept deleting things until I got that error. This is clearly some bug in Pip. I have version 18.1 on Windows 10 for Python 3.7 on my machine.)这是因为
-e
标志表示“可编辑”,并且与python setup.pydevelop
相同,它从创建符号链接;
到您的site-packages
目录,并且不运行常规安装。查看 SpiffWorkflow 的
setup.py
我可以看到问题出在哪里:它说包内容位于
src
,而不是spiffworkflow
(开发模式期望什么)。您只需删除
-e
标志即可:参考资料:
It is because the flag
-e
means "editable", and it is the same doingpython setup.py develop
, that creates a symbolic link from<PACKAGE_NAME_LOWERCASE>
to yoursite-packages
directory and not running an usual installation.Looking at SpiffWorkflow's
setup.py
I can see where the problem relies:It says that the package content is located at
src
, instead ofspiffworkflow
(what develop mode expects).You can just drop the
-e
flag and be happy:References:
就我而言,问题在于
package_dir = {'': './src'}
:我已指定 dir 的 path,而不是 dir name >,出于某种原因,它与 setup.py bdist_wheel 配合得很好。In my case problem was with
package_dir = {'': './src'}
: I have specified path to dir, rather than dir name, which for some reason worked fine withsetup.py bdist_wheel
.我的项目有以下结构:
基本上,所有 python 代码都在
/src/project
中。这可以避免从测试脚本或其他脚本中直接导入project
。setup.py
内容:现在我想将所有这些都拉到下面一层,以便整个项目可以有不同的组件,如下所示:
所以当我尝试
pip install -e .
,即使在尝试修复所有路径之后也是如此。我通过更新 setup.py 解决了这个问题:
希望这有帮助!
I had the followng structure for my project:
So basically, all python code in
/src/project
. This permits to avoidproject
to be directly imported from tests scripts or whatever.setup.py
content:Now I want to pull all this one level below, so that the overall project can have different components, as follows:
So I got the error message as in OP when trying to
pip install -e .
, even after trying to fix all paths.I solved it by following update in
setup.py
:Hope this helps!
就我而言,
https://github.com/quiver-team/torch-quiver/blob/main/setup.py
我从包目录配置的开头删除了
./
字符。而且我安装成功了。
参考https://github.com/pypa/setuptools/discussions/3755
In my cases,
https://github.com/quiver-team/torch-quiver/blob/main/setup.py
I remove the
./
chars from the beginning of my package dir configuration.And I install it successfully.
refer to https://github.com/pypa/setuptools/discussions/3755