使用 Jenkins 将 pip 安装在可嵌入的 python 上

问题描述 投票:0回答:1

我有一个 Windows Jenkins 工作程序,它有一个可嵌入的 python,它需要在其上安装一些软件包。 python已经有pip,使用get-pip.py安装。我还修改了 python38._pth,如另一篇 SO 帖子中所示:

python38.zip
.
Lib
Lib/site-packages
# Uncomment to run site.main() automatically
#import site

不确定是否有帮助,但管道的相关部分是:

dir('env'){
    bat '''
        .\\python.exe -m pip config --user set global.extra-index-url "<url>"
        .\\python.exe -m pip install -r requirements.txt --force-reinstall
        .\\python.exe -m pip list
    '''
        }

使用 python 3.8.9 时,管道出现以下错误:

ERROR: Exception:
Traceback (most recent call last):
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\cli\req_command.py", line 248, in wrapper
    return func(self, options, args)
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\commands\install.py", line 452, in run
    installed = install_given_reqs(
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\req\__init__.py", line 72, in install_given_reqs
    requirement.install(
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\req\req_install.py", line 780, in install
    scheme = get_scheme(
  File "D:\jenkins\workspace\<repo-name_><branch-name>\env\Lib/site-packages\pip\_internal\locations\__init__.py", line 249, in get_scheme
    old = _distutils.get_scheme(
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\locations\_distutils.py", line 141, in get_scheme
    scheme = distutils_scheme(dist_name, user, home, root, isolated, prefix)
  File "D:\jenkins\workspace\<repo-name>_<branch-name>\env\Lib/site-packages\pip\_internal\locations\_distutils.py", line 80, in distutils_scheme
    i.finalize_options()
  File "distutils\command\install.py", line 344, in finalize_options
  File "distutils\command\install.py", line 487, in convert_paths
  File "distutils\util.py", line 122, in convert_path
ValueError: path '/scratch/data/jenkins/workspace/<repo-name>_<branch-name>_tmp/.local' cannot be absolute

奇怪的是,我还尝试了可嵌入的 python 3.10 和完全相同的管道,并且在该版本上它工作没有任何问题。

这是我第一次使用 Jenkins,所以如果我看起来有点迷失,请原谅。任何帮助将不胜感激

python jenkins pip distutils
1个回答
0
投票

我的错误似乎是将 PYTHONUSERBASE 定义为管道中的环境变量。尽管使用带有嵌入式 python 的 pip 将包本身放入本地 site-packages 目录中,但该变量似乎会干扰该过程。 (我假设在尝试找出安装包的位置时)

© www.soinside.com 2019 - 2024. All rights reserved.