# 安裝 TWCC CLI 並登入
以下以 TWS Ubuntu 24.04 以及 Windows Server 2022 為操作範例,若 OS 版本不相同流程可能會有差異,再請您自行查找版本適用的相關流程。
[TOC]
## Step 1. 建立 VCS (使用地端主機可略)
:::info
以下操作以此版本為例:


:::
步驟請參考:https://docs.twcc.ai/docs/user-guides/twcc/vcs/create-instance
## Step 2. 安裝 TWCC CLI
### Ubuntu 24.04
- 安裝虛擬環境工具(如果尚未安裝)
```
sudo apt install python3-venv
```
- 創建一個虛擬環境
```
python3 -m venv myenv
```
- 啟動虛擬環境
```
source myenv/bin/activate
```
- 在虛擬環境中安裝所需的套件
```
pip3 install -U TWCC-CLI
```
- 更新工具
```
pip3 install --upgrade setuptools
```
### Windows Server 2022
- 連線進入 VCS 後,下載並安裝 [Python](https://www.python.org/downloads/windows/)
將以下選項打勾:

- 確認安裝成功
- 開啟 PowerShell
- 輸入 python --verison,成功安裝將返回版本號碼

- 安裝 TWCC CLI
```
pip3 install -U TWCC-CLI
```
- 更新工具
```
pip3 install --upgrade setuptools
```
- 輸入 twcccli 確認已安裝成功

## Step 3. 登入
### 1. 取得專案代碼

### 2. 取得您的 API 金鑰
點擊平台右上角名稱 > API金鑰管理 > 複製金鑰

### 3. 設定登入檔案,登入完成
```
1. 輸入 twccli config init
2. Y
3. 輸入專案代碼
4. 輸入 API 金鑰
```

- 登入成功
- Ubuntu 24.04

- Windows Server 2022

## Step 4. 如何使用 TWCC CLI 管理資源
指令集請參考:https://twcc-cli.readthedocs.io/en/latest/twccli-ch.html
## 檢視當前使用專案、用戶資訊
```
twccli config whoami
```
## 更換專案、用戶身份
先移除以下資料夾,再重新執行 [Step3. 登入](#Step-3-登入)
```
rm -rf ~/.twcc_data
```
:::info
其他資訊請參考:https://man.twcc.ai/@twccdocs/doc-cli-main-zh/https%3A%2F%2Fman.twcc.ai%2F%40twccdocs%2Fguide-cli-signin-zh
:::