序言

最近发现3D打印群里的越来越多人想去尝试Klipper固件了,想必它的可扩展性和易于配置吸引了不少人。加上近期百无聊赖,于是就想写出这样一篇安装教程,供各位参考。

开始

首先,你需要一个装有Debian系操作系统(如Debian、Ubuntu、Raspbian、Armbian等)的设备(电脑、瘦客户机、树莓派、玩客云等等……)。

安装前的准备

更换系统软件源

如果使用Ubuntu系统,可运行以下指令,将系统自带的软件源替换为国内的软件源:

# 清华源
sudo sed -i "s/http:\/\/cn.archive.ubuntu.com/https:\/\/mirrors.tuna.tsinghua.edu.cn/g" /etc/apt/sources.list
sudo sed -i "s/http:\/\/security.ubuntu.com/https:\/\/mirrors.tuna.tsinghua.edu.cn/g" /etc/apt/sources.list
# 中科大源
sudo sed -i "s/http:\/\/cn.archive.ubuntu.com/https:\/\/mirrors.ustc.edu.cn/g" /etc/apt/sources.list
sudo sed -i "s/http:\/\/security.ubuntu.com/https:\/\/mirrors.ustc.edu.cn/g" /etc/apt/sources.list
# 阿里云源
sudo sed -i "s/http:\/\/cn.archive.ubuntu.com/https:\/\/mirrors.aliyun.com/g" /etc/apt/sources.list
sudo sed -i "s/http:\/\/security.ubuntu.com/https:\/\/mirrors.aliyun.com/g" /etc/apt/sources.list

其它系统(Debian、Raspbian等)可参照清华源提供的教程来更换软件源。
更换好软件源后,运行sudo apt updatesudo apt upgrade来更新系统。

安装必要软件

Klipper相关的软件需要Python等软件才能运行,且需要git来同步最新的Klipper等软件源代码,所以需要使用sudo apt install build-essential python3 python3-pip git来安装必要的软件。
安装好pip后,运行pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple更换pip的源。
也可以将链接替换为下列链接中的其中之一:

# 豆瓣源
https://pypi.doubanio.com/simple
# 腾讯源
https://mirrors.cloud.tencent.com/pypi/simple
# 阿里源
https://mirrors.aliyun.com/pypi/simple

如果使用树莓派,请删除/etc/pip.conf文件中的所有内容,否则可能会导致换源后下载依旧缓慢!

安装

在本教程中,我们使用KIAUH脚本来安装Klipper+Moonraker+Fluidd。
首先,使用git clone https://github.com/th33xitus/kiauh下载KIAUH脚本。如果所在地的GitHub速度缓慢,可使用此镜像git clone https://gitee.com/miroky/kiauh或以下代理加速:

以下代理列表不再维护,不保证有效性。
国内用户强烈建议使用上面的gitee源下载或自行寻找有效的GitHub代理!

# 使用下列命令中的其中一个即可!
# 代理1
git clone https://gitclone.com/github.com/th33xitus/kiauh
# 代理2
git clone https://ghproxy.com/github.com/th33xitus/kiauh
# 代理3
git clone https://api.mtr.pub/th33xitus/kiauh

更换下载源

如果使用上文中提到的gitee源,请直接略过此步骤。

KIAUH使用GitHub来获取代码,在国内可能会导致下载缓慢。
获取到脚本后不要急着运行,cd进入kiauh目录后,先使用下列命令修改scripts/globals.sh中的地址,通过代理服务加速源代码的获取:

# 更换除 Klipper 下载链接的所有其他下载链接
sed -i '40,$s|https://github.com/|https://gitclone.com/github.com/|g' scripts/globals.sh
# 更改 Klipper 安装脚本中的链接处理部分,使其无论如何都使用 gitclone.com 作为加速源
sed -i 's|repo="https://github.com/${repo}"|repo="https://gitclone.com/github.com/${repo}"|g' scripts/klipper.sh
# 如果要安装 Mainsail 而不是 Fluidd ,请将下面两行中的 fluidd.sh 改为 mainsail.sh
sed -i 's/raw.githubusercontent.com/raw.0z.gs/g' scripts/fluidd.sh
sed -i 's/github.com/download.0z.gs/g' scripts/fluidd.sh
PS:废话一下raw.0z.gs貌似已经废了不建议使用改成gitclnoe.con或者ghproxy.net/com
sed -i 's/raw.githubusercontent.com/gitclone.com/g' scripts/fluidd.sh
sed -i 's/github.com/gitclone.com/g' scripts/fluidd.sh

安装

Klipper

运行kiauh.sh,出现如下界面(可以看到所有软件都显示为Not Installed):

选择1) [Install]后,出现如下界面:

选择1) [Klipper]来安装Klipper。
首先是选择Python版本的界面,因Python 2早已停止维护,不建议使用Python 2环境安装,直接选择Python 3环境安装即可。

/=======================================================\
|     ~~~~~~~~~~~~~~~~~ [ KIAUH ] ~~~~~~~~~~~~~~~~~     |
|         Klipper Installation And Update Helper        |
|     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     |
\=======================================================/
/=======================================================\
| Please select the preferred Python version.           | 
| The recommended version is Python 2.7.                | 
|                                                       |
| Installing Klipper with Python 3 is officially not    | 
| recommended and should be considered as experimental. | 
|-------------------------------------------------------|
|  1) [Python 2.7] (recommended)                        | 
|  2) [Python 3.x] (experimental)                       | 
|-------------------------------------------------------|
|                       B) « Back                       |
\=======================================================/
###### Select Python version: 

下一步会询问安装Klipper的实例数量,如果只连接一台打印机,只需安装一个实例。
这里以一台打印机为例,按两下回车继续。

###### Initializing Klipper installation ...
/=======================================================\
| Please select the number of Klipper instances to set  |
| up. The number of Klipper instances will determine    |
| the amount of printers you can run from this host.    |
|                                                       |
| WARNING:                                              |
| Setting up too many instances may crash your system.  |
\=======================================================/
###### Number of Klipper instances to set up: 1
 [➔] 1
###### Install 1 instance(s)? (Y/n): 

此时KIAUH便会开始Klipper的安装,只需稍作等待即可。
安装过程中需要安装并更新软件,可能需要系统的管理员密码。
安装好Klipper后,可能会询问是否将当前用户加入tty、dialout等用户组,用于解决可能无法连接下位机的问题,回车确认即可。
/=======================================================\
| WARNING: Your current user is not in group:           |
| ● tty                                                 |
| ● dialout                                             |
|                                                       |
| It is possible that you won't be able to successfully |
| connect and/or flash the controller board without     |
| your user being a member of that group.               |
| If you want to add the current user to the group(s)   |
| listed above, answer with 'Y'. Else skip with 'n'.    |
|                                                       |
| INFO:                                                 |
| Relog required for group assignments to take effect!  |
\=======================================================/
###### Add user '用户名' to group(s) now? (Y/n): 

Moonraker

在Installation Menu界面选择2) [Moonraker]即可开始安装。

###### Initializing Moonraker installation ...
[✓ OK] Klipper installation found!

###### Install Moonraker? (Y/n): 

安装完成后会显示Moonraker的IP地址:
#########################################################
 Moonraker has been set up! 
#########################################################

        Instance 1: 192.168.2.235:7125

使用浏览器访问此地址后,显示类似如下内容即表示安装成功:

Mainsail/Fluidd

以下提示均以安装Fluidd为例,Mainsail安装过程与Fluidd大同小异,故不再赘述。

Installation Menu界面中选择3) [Mainsail]4) [Fluidd]即可开始安装。

KIAUH目前临时禁用了安装摄像头的功能,以下提示不会再出现。
如需摄像头支持,需要自行安装配置mjpg-streamer或crowsnest。

脚本会在安装Nginx后询问是否安装MJPG-Streamer,如果计划使用树莓派的摄像头或USB摄像头,可以输入Y,在此处安装。否则一般情况下无需安装,按回车即可。

现在kiauh是推荐安装Crowsnest这个组件,在安装完成后请参考站内文章完成对摄像头的配置

/=======================================================\
| Install MJGP-Streamer for webcam support?             |
\=======================================================/
###### Please select (y/N):

这一步完成后会下载并部署Fluidd或Mainsail,完成后会询问是否添加常用的gcode脚本,一般情况下直接回车安装即可: 
/=======================================================\
| It is recommended to have some important macros in    |
| your printer configuration to have Fluidd fully       |
| functional and working.                               |
|                                                       |
| The recommended macros for Fluidd can be found here:  |
| https://docs.fluidd.xyz/configuration/initial_setup   |
|                                                       |
| If you already have these macros in your config file, |
| skip this step and answer with 'no'.                  |
| Otherwise you should consider to answer with 'yes' to |
| add the recommended example macros to your config.    |
\=======================================================/
###### Add the recommended macros? (Y/n): 

等待片刻,Fluidd或Mainsail即可安装完成。
如果在已经登陆图形界面且带有浏览器的系统安装,可进入浏览器访问127.0.0.1或localhost,网页加载成功即为完成安装。
如果在远程连接的系统上安装,可以在同一局域网下使用浏览器访问系统的IP地址,查看网页是否加载成功。
myxiaowu

作者 myxiaowu

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注