aider中文文檔網站上給出的安裝說明比較簡單:
https://aider.doczh.com/docs/install.html
但是在一個干凈的ubuntu環境中按文檔中的命令安裝時,會報錯,經過一番嘗試之后,解決了報錯問題,成功完成了安裝。
成功安裝執行的命令如下,大家可以直接取用(注意,新版本的ubuntu上默認安裝的是python3,而非python,所以下面命令中都是用的python3):
sudo apt install python3-pip?python3.12-venvpython3 -m venv myenvsource myenv/bin/activatepip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simplepip install aider-installUV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple aider-install
下面是問題的解決過程,大家感興趣的話可以參考一下,不感興趣可以直接忽略。
按aider中文文檔中的說明執行命令:
python3 -m pip install aider-install
報錯:
/usr/bin/python3: No module named pip
很明顯,是說缺少pip模塊。但是用?
sudo apt install python3-pip
命令安裝了pip后,運行前面的命令依然報錯,這次報的是:
error: externally-managed-environment× This environment is externally managed
╰─> To install Python packages system-wide, try apt installpython3-xyz, where xyz is the package you are trying toinstall.If you wish to install a non-Debian-packaged Python package,create a virtual environment using python3 -m venv path/to/venv.Then use path/to/venv/bin/python and path/to/venv/bin/pip. Makesure you have python3-full installed.If you wish to install a non-Debian packaged Python application,it may be easiest to use pipx install xyz, which will manage avirtual environment for you. Make sure you have pipx installed.See /usr/share/doc/python3.12/README.venv for more information.note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
是說需要在虛擬環境中安裝python包。
于是執行創建虛擬環境的命令:
python3 -m venv myenv
又報錯了:
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.apt install python3.12-venvYou may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.Failing command: /home/teratech/erule-web-3.0/myenv/bin/python3
是說venv模塊沒有安裝,于是再運行
apt install python3.12-venv
命令安裝venv。
安裝完成后,再次運行
python3 -m venv myenv
命令,虛擬環境創建成功。
然后引用虛擬環境:
source myenv/bin/activate
引用后,命令提示符前出現?(myenv) 標識,說明已經進入了虛擬環境。
更換pip鏡像源(重要??,否則后續安裝aider-install和用aider-install安裝aider時會報超時錯誤):
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
這時再執行安裝aider的命令:
pip install aider-install
安裝 aider-install 成功:
Collecting aider-installDownloading aider_install-0.2.0-py3-none-any.whl.metadata (2.0 kB)
Collecting uv>=0.5.0 (from aider-install)Downloading uv-0.8.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
Downloading aider_install-0.2.0-py3-none-any.whl (6.9 kB)
Downloading uv-0.8.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.0 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.0/21.0 MB 15.5 kB/s eta 0:00:00
Installing collected packages: uv, aider-install
Successfully installed aider-install-0.2.0 uv-0.8.15
然后運行:
UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple aider-install
命令,并最終安裝成功:
Installed 1 executable: aider
注意:UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple 一定要加,因為aider-install命令內部是使用的是uv工具(Ultra-Violet)進行安裝,而非直接調用pip。因此即使我們前面已經配置了pip的清華源,該命令仍會使用uv默認的下載通道,導致超時問題。
安裝完成后,需要運行一下更新shell的命令:
. ~/.bashrc
來讓 .local/bin 目錄被加到 PATH 中,從而讓 aider 命令能被找到。
更新完shell后,運行 aider 命令,就可以使用aider了:
~$ aider
────────────────────────────────────────────────────────────────────────────────
Aider respects your privacy and never collects your code, chat messages, keys orpersonal info.
For more info: https://aider.chat/docs/more/analytics.html
Allow collection of anonymous analytics to help improve aider? (Y)es/(N)o [Yes]: