Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何让GitHub操作运行程序找到使用“pip install--user”安装的可执行文件?_Python_Macos_Pip_Github Actions - Fatal编程技术网

Python 如何让GitHub操作运行程序找到使用“pip install--user”安装的可执行文件?

Python 如何让GitHub操作运行程序找到使用“pip install--user”安装的可执行文件?,python,macos,pip,github-actions,Python,Macos,Pip,Github Actions,在github action runners上使用python3-m pip安装--user foo时,假设foo包包含一个可执行的bar 我想知道用户bin目录在Linux、Windows和MacOS Runner上的位置,以便将其添加到GITHUB\u PATH 因此后续调用,如命令-v bar,哪个bar或bar不会失败 编辑: 在Linux上,使用bash,它将是: run:echo“$HOME/.local/bin”>>$GITHUB\u路径 在Windows上,使用powers

在github action runners上使用
python3-m pip安装--user foo
时,假设
foo
包包含一个可执行的
bar

我想知道用户bin目录在Linux、Windows和MacOS Runner上的位置,以便将其添加到
GITHUB\u PATH

因此后续调用,如
命令-v bar
哪个bar
bar
不会失败

编辑:

  • 在Linux上,使用bash,它将是:
    run:echo“$HOME/.local/bin”>>$GITHUB\u路径
    
  • 在Windows上,使用powershell,它可以是:
    run:echo“$(Get Item~).FullName)/AppData/Roaming/Python/Python37/Scripts”| Out文件-文件路径$env:GITHUB_路径-编码utf8-追加
    
  • 在MacOS上,使用bash,它将是:
    run:echo“$HOME/Library/Python/3.9/bin”>>$GITHUB\u路径
    

我认为下面应该给出预期的结果

import os
import sysconfig

user_scripts_path = sysconfig.get_path('scripts', f'{os.name}_user')
print(user_scripts_path)
但可能是pip在内部使用了不同的逻辑(可能基于),但结果应该是相同的

参考资料


在任何平台上,它都是
python-m站点下的
bin
目录——用户群
@an在Windows上它是
PythonXY/Scripts
而不是
bin
这是否回答了您的问题?