首页 > 解决方案 > PIP 安装:无法组合 --user 和 --target

问题描述

我的目标是将包安装到我机器上的特定目录中,以便我可以将其打包以与 AWS Lambda 一起使用。

这是我尝试过的:
pip install snowflake-connector-python -t .

pip install --system --target=C:\Users\path2folder --install-option=--install-scripts=C:\Users\path2folder --upgrade snowflake-connector-python

这两个选项都返回了以下错误消息:
ERROR: Can not combine '--user' and '--target'

为了使 AWS Lambda 函数正常工作,我需要将我的依赖项安装在特定目录中,以创建一个 .zip 文件进行部署。我已经通过 Google 和 StackOverflow 进行了搜索,但还没有看到回答这个问题的线程。

更新:这在 Mac 上似乎不是问题。所描述的问题是在 Windows 10 上。

标签: pythonpipcommand-line-interface

解决方案


pip install --target ./py_pkg -r requirements.txt --upgrade在使用 Microsoft Store 版本的 Python 3.9运行时,我们遇到了同样的问题。

添加--no-user到最后似乎解决了这个问题。也许你可以在你的命令中尝试一下,让我们知道这个解决方案是否有效?

pip install --target ./py_pkg -r requirements.txt --upgrade --no-user


推荐阅读