Python gRPC SDK
基本安装
pip
. 安装它所需要做的就是运行:
pip install stability-sdk
开发者安装
0.(可选)创建并激活Python虚拟环境...
venv
Python 安装附带的模块,创建一个名为“venv”的虚拟环境:
python3 -m venv venv
python3
在这里调用来访问“系统”Python 可执行文件。
source venv/bin/activate
# prompt before activating
/path/to/current/directory >
# prompt after activating
(venv) /path/to/current/directory >
python
将访问激活环境的 Python 可执行文件,而不是系统 Python。安装 Python 包——无论是从源代码(如下所述)还是通过 pip——只会影响环境 Python 可执行文件。deactivate
。1.stability-sdk
1.从 GitHub克隆存储库...
stability-sdk
库(从 0.3.0 开始)依赖于 git 子模块。要在克隆时获取这些子模块,请使用--recurse-submodules
参数:
git clone --recurse-submodules https://github.com/Stability-AI/stability-sdk
git submodule init
git submodule update
--branch
:
git clone --branch branchName --recurse-submodules https://github.com/Stability-AI/stability-sdk
switch
在克隆后使用该命令拉取并检出到origin
远程托管的任何分支(按照这些说明,您的原始远程将设置为https://github.com/stability-ai/stability-sdk.git) 。导航到存储库后:git fetch
git switch branchName
2. 导航到stability-sdk
存储库目录...
cd stability-sdk
3.安装Python SDK...
.
)作为参数传递:
pip install .
-e
参数:
pip install -e 。
4. (可选)设置STABILITY_HOST
和STABILITY_KEY
环境变量...
export
是 Linux / MacOS 语法。如果您使用的是 Windows,则需要使用该set
命令。# Sign up for an account at the following link to get an API Key.
# https://platform.stability.ai/
# Click on the following link once you have created an account to be taken to your API Key.
# https://platform.stability.ai/account/keys
# Paste your API Key below.
export STABILITY_HOST=grpc.stability.ai:443
export STABILITY_KEY=yourkeyhere
5. 调用 API 来测试您的设置...
python -m stability_sdk generate "A stunning house."
修改于 2023-12-14 07:07:00