我正在尝试为我的项目配置发布管道。其中一项工作是一个简单的bash脚本,用于将代码发布到PyPI:
python3 -V
python3 setup.py build && python3 setup.py sdist
twine upload dist/wordsearch*.tar.gz --config-file $(PYPIRC_PATH)
但是,当我运行一个发行版时,会出现以下错误:
2018-12-13T00:28:28.8474589Z ##[section]Starting: Publish Script
2018-12-13T00:28:28.8478332Z ==============================================================================
2018-12-13T00:28:28.8478459Z Task : Bash
2018-12-13T00:28:28.8478532Z Description : Run a Bash script on macOS, Linux, or Windows
2018-12-13T00:28:28.8478635Z Version : 3.142.2
2018-12-13T00:28:28.8478736Z Author : Microsoft Corporation
2018-12-13T00:28:28.8478819Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613738)
2018-12-13T00:28:28.8478963Z ==============================================================================
2018-12-13T00:28:29.5748147Z Generating script.
2018-12-13T00:28:29.5751467Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/0e077afa-4419-4ee3-9aa8-c1b9b1f16b85.sh
2018-12-13T00:28:29.5751681Z Python 3.5.2
2018-12-13T00:28:29.7992675Z Traceback (most recent call last):
2018-12-13T00:28:29.8002462Z File "setup.py", line 17, in <module>
2018-12-13T00:28:29.8002681Z from setuptools import setup, find_packages
2018-12-13T00:28:29.8003469Z ImportError: No module named 'setuptools'
2018-12-13T00:28:29.8108863Z /home/vsts/work/_temp/0e077afa-4419-4ee3-9aa8-c1b9b1f16b85.sh: line 5: twine: command not found
2018-12-13T00:28:29.8229014Z ##[error]Bash exited with code '127'.
2018-12-13T00:28:29.8257310Z ##[section]Finishing: Publish Script
我收集到的是我缺少setuptools和麻线。异常之处在于setuptools应该内置在Python库中,但是存在导入错误。
我在脚本之前有一个Twine Authentication作业,并且已经验证setup.py文件存在:
我是否缺少组件,还是忽略了某些内容?预先谢谢你。
答案 0 :(得分:0)
要完成此操作,您将需要使用python -m twine
而不是普通的“ twine”命令。 “ pip install”将麻线二进制文件放在不在$ PATH中的代理上运行的用户位置(类似于/home/vsts/.local/bin)。
对于类似的问题,您可以使用诸如find ~ -name twine && echo $PATH
之类的shell命令放置调试步骤