在python程式開發的過程中,通常會裝很多的套件來使用,但這些套件之間可能會有版本相容的問題,所以我們通常會使用虛擬環境來維護專案所需要的套件,這邊簡單介紹conda的環境設定以及語言模型開發會用到的套件安裝:
到anaconda 首頁下載:https://docs.anaconda.com/miniconda/miniconda-install/
(安裝miniconda會比較輕量)
根據OS選擇要下載的安裝包:
打開安裝包進行安裝設定:
等進度條跑完就安裝完成了!
載完之後使用下列指定到終端機建立一個python的虛擬環境:
## Input:
conda create --name iTH-GenAI-Chaos python==3.10
## Output:
Channels:
- defaults
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /opt/miniconda3/envs/iTH-GenAI-Chaos
added / updated specs:
- python==3.10
The following packages will be downloaded:
package | build
---------------------------|-----------------
pip-24.2 | py310hca03da5_0 2.3 MB
python-3.10.0 | hbdb9e5c_5 12.6 MB
setuptools-72.1.0 | py310hca03da5_0 2.4 MB
wheel-0.43.0 | py310hca03da5_0 108 KB
------------------------------------------------------------
Total: 17.4 MB
The following NEW packages will be INSTALLED:
bzip2 pkgs/main/osx-arm64::bzip2-1.0.8-h80987f9_6
ca-certificates pkgs/main/osx-arm64::ca-certificates-2024.7.2-hca03da5_0
libffi pkgs/main/osx-arm64::libffi-3.4.4-hca03da5_1
ncurses pkgs/main/osx-arm64::ncurses-6.4-h313beb8_0
openssl pkgs/main/osx-arm64::openssl-1.1.1w-h1a28f6b_0
pip pkgs/main/osx-arm64::pip-24.2-py310hca03da5_0
python pkgs/main/osx-arm64::python-3.10.0-hbdb9e5c_5
readline pkgs/main/osx-arm64::readline-8.2-h1a28f6b_0
setuptools pkgs/main/osx-arm64::setuptools-72.1.0-py310hca03da5_0
sqlite pkgs/main/osx-arm64::sqlite-3.45.3-h80987f9_0
tk pkgs/main/osx-arm64::tk-8.6.14-h6ba3021_0
tzdata pkgs/main/noarch::tzdata-2024a-h04d1e81_0
wheel pkgs/main/osx-arm64::wheel-0.43.0-py310hca03da5_0
xz pkgs/main/osx-arm64::xz-5.4.6-h80987f9_1
zlib pkgs/main/osx-arm64::zlib-1.2.13-h18a0788_1
Proceed ([y]/n)?
## Input: 按下Enter!
## Output:
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate iTH-GenAI-Chaos
#
# To deactivate an active environment, use
#
# $ conda deactivate
這樣一個新的python環境就安裝好,然後我們只要根據以上提示使用conda activate,就能進入我們新的python環境拉~
## Input:
conda activate iTH-GenAI-Chaos
安裝環境變數套件:
pip install python-dotenv==1.0.1
安裝jupyter:
pip install jupyter==1.1.1
如果要離開這個環境,回到你原系統使用python的話可以用下面這個指令:
## Input:
conda deactivate
pip install langchain langchain_community
pip install openai
pip install boto3
pip install faiss-cpu
pip install -qU langchain-text-splitters
pip install streamlit