FreeBSD下不能直接安裝g4f,因為Curl_cffi這個庫裝不上。0.5.0.3這個版本不需要這個庫,所以可以安裝。
那么就沒有辦法安裝新版本了嗎? 有的,就是在linux仿真環境下。
Linux仿真環境安裝g4f
最簡單的方法是使用chroot進入linux仿真環境,然后在里面安裝新版本的g4f
# 進入linux仿真環境
sudo chroot /compact/ubuntu22 /bin/bash# 啟動python環境
source ub22py312/bin/activate
pip install pip -U
pip install g4f[all] -U
g4f gui
這個方法下成功安裝了最新版本的0.5.7.3版本
但是這個方法雖然簡單,使用起來卻有些繁瑣,需要sudo權限
在FreeBSD下安裝Conda,然后在Conda環境下安裝G4F
更好一點的方法,是直接在FreeBSD下安裝Conda,然后在Conda環境下安裝G4F
在FreeBSD下安裝Conda參考:在FreeBSD14.2下安裝MiniConda python3.12 ,以便安裝運行Auto-Coder_freebsd conda-CSDN博客
但是現在碰到問題,就是markitdown這個庫的新版本無法安裝上,進而導致g4f的gui無法啟動
解決依賴庫markitdown
使用--no-deps
pip install markitdown==0.1.2 --no--deps
解決magika庫?
這時候報:No module named 'magika'
pip install magika --no--deps
這時候報:?No module named 'onnxruntime'
解決安裝onnxruntime庫?
發現無法用pip安裝onnxruntime
FreeBSD系統里onnxruntime安裝包,但是因為沒有裝在python下,無法用。
FreeBSD系統下還有py311的onnxruntime包,但是因為現在是python3.12環境,也無法用。
用conda命令安裝onnxruntime庫
conda install onnxruntime
如果速度慢,可以加鏡像
創建.condarc文件
conda config --set show_channel_urls yes
在.condarc文件中加入清華鏡像
channels:- defaults
show_channel_urls: true
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
?安裝完成,測試g4f
?g4f gui
啟動成功!
瀏覽器瀏覽的8080端口,網站正常。
結論
關于在FreeBSD系統下使用f4f,如果用完全的仿真,那么很容易安裝g4f
如果是conda仿真,那么onnxruntime庫可能無法用pip安裝,需要使用conda來看著。
調試
用conda安裝markitdown的時候,報錯RemoveError: 'pluggy'
Verifying transaction: failed ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
RemoveError: 'pluggy' is a dependency of conda and cannot be removed from ? ? ? ? ? ??
conda's operating environment. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
pip uninstall pluggy
最終解決見后面隔一個問題。?
刪除pluggy后報錯conda info could not be constructed.(不應該刪除,這步可以跳過)
conda info could not be constructed.
KeyError('active_prefix_name')
An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.
執行
conda --no-plugins install markitdown[all]
不行。不得已,又把pluggy安裝上
pip install pluggy
conda裝什么都報錯RemoveError: 'pluggy'
嘗試強制重裝核心
conda update conda --force-reinstall # 強制重裝Conda核心組件?:ml-citation{ref="1,3" data="citationList"}
不行
切換清華源解析
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/?:ml-citation{ref="6" data="citationList"}
conda update --all --channel defaults # 優先使用默認通道?:ml-citation{ref="5,6" data="citationList"}
哇塞,終于搞定了!
問題的原因,有可能是切換清華源,但沒有切換干凈.....