Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the simply-static domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/wp-includes/functions.php on line 6121
猫盘->群晖->网站

猫盘->群晖->网站

今天折腾群晖迷你Linux系统的时候遇到一个问题,Python写的程序基本上都会带上一些扩展包,今天在安装BeautifulSoup网页解析工具的时候遇到了麻烦。由于群晖迷你Linux系统阉割了很多功能,问题如下。

在安装BeautifulSoup网页解析包时,一般使用pip工具来安装,然而没有pip。

没有pip那就只好先安装pip工具了,要安装pip工具得先安装个epel-release,使用yum安装,提示没有yum。

安装yum提示没有rpm管理器,python缺失?

既然这些软件工具安装不了,那就只好下载yum源码编译安装,然而还是报错。

解决办法

直接下载pip源码编译安装即可。

首先通过群晖套件安装python3

然后安装setuptools工具,执行如下命令下载源码

wget --no-check-certificate https://files.pythonhosted.org/packages/6a/fa/5ec0fa9095c9b72cb1c31a8175c4c6745bf5927d1045d7a70df35d54944f/setuptools-59.6.0.tar.gz

然后解压

tar -zxvf setuptools-59.6.0.tar.gz

进入解压目录

cd setuptools-59.6.0

使用python3编译

python3 setup.py build

使用python3安装

python3 setup.py install

安装pip,执行下面命令下载到当前目录

wget --no-check-certificate https://files.pythonhosted.org/packages/da/f6/c83229dcc3635cdeb51874184241a9508ada15d8baa337a41093fab58011/pip-21.3.1.tar.gz

解压

tar -zxvf pip-21.3.1.tar.gz

进入pip目录

cd pip-21.3.1

python3编译

python3 setup.py build

python3安装

python3 setup.py install

设置环境变量

export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/volume1/@appstore/py3k/usr/local/bin"

由于每次关机环境变量会变化,所以大家最好一次将需要的扩展包下载完,不然以后再安装就需要再执行一下最后一句命令。

然后使用如下命令安装beautifulsoup扩展

pip3 install beautifulsoup4 datetime lxml pygame requests

安装完成后,运行python,然后执行下面代码不报错即可

from bs4 import BeautifulSoup

安装pip也可以按如下方式

执行sudo apt-get install python3-pip
若报 No module named ‘distutils.util’,执行 sudo apt-get install python3-distutils
若报E: Package python3-distutils has no installation candidate,执行: sudo apt update
再重新执行:sudo apt-get install python3-distutils
再执行:sudo apt-get install pyton3-pip