FreeBSD Conda Python3.12下安装GPT4Free(g4f)0.5.7.3版本

发布于:2025-07-18 ⋅ 阅读:(19) ⋅ 点赞:(0)

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/cloud
  pytorch: 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"}

哇塞,终于搞定了!

问题的原因,有可能是切换清华源,但没有切换干净.....


网站公告

今日签到

点亮在社区的每一天
去签到