pgAdmin4的安装参照官网,在Ubuntu22.04时都能正常安装成功,并且能正常使用
然而要命的是升级了Ubuntu22.10后,无论是之前安装好的,或重新安装pgAdmin4都失败了!!
官方方法如下:
#
# Setup the repository
#
# Install the public key for the repository (if not done previously):
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
# Create the repository configuration file:
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
#
# Install pgAdmin
#
# Install for both desktop and web modes:
sudo apt install pgadmin4
# Install for desktop mode only:
sudo apt install pgadmin4-desktop
想了一下,仔细对照下,发现“Create the repository configuration file:”这一步对应安装出错提示中无“release”
那么只能把原来的:sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
改为:sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/impish pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
这样子可以安装对应低版ubuntu 22.04的
经改造后,很顺利安装成功了!!!然而却在启动时报如下图错误:
把错误复制出来如下: pgAdmin Runtime Environment -------------------------------------------------------- Python Path: "/usr/pgadmin4/venv/bin/python3" Runtime Config File: "/home/luck/.config/pgadmin/runtime_config.json" pgAdmin Config File: "/usr/pgadmin4/web/config.py" Webapp Path: "/usr/pgadmin4/web/pgAdmin4.py" pgAdmin Command: "/usr/pgadmin4/venv/bin/python3 -s /usr/pgadmin4/web/pgAdmin4.py" Environment: - LANGUAGE: zh_CN:zh:en_US:en - USER: luck - LC_TIME: zh_CN.UTF-8 - XDG_SEAT: seat0 - XDG_SESSION_TYPE: x11 - SHLVL: 0 - HOME: /home/luck - DESKTOP_SESSION: xubuntu - XDG_SEAT_PATH: /org/freedesktop/DisplayManager/Seat0 - SDL_IM_MODULE: fcitx - LC_MONETARY: zh_CN.UTF-8 - DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus - DEBUGINFOD_URLS: https://debuginfod.ubuntu.com - QT_QPA_PLATFORMTHEME: gtk2 - GTK_IM_MODULE: fcitx - LOGNAME: luck - XDG_SESSION_CLASS: user - CLUTTER_BACKEND: x11 - GTK_OVERLAY_SCROLLING: 0 - XDG_SESSION_ID: c2 - PATH: /home/luck/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin - GDM_LANG: zh_CN - XDG_SESSION_PATH: /org/freedesktop/DisplayManager/Session0 - LC_ADDRESS: zh_CN.UTF-8 - XDG_RUNTIME_DIR: /run/user/1000 - XDG_MENU_PREFIX: xfce- - LANG: zh_CN.UTF-8 - XDG_CURRENT_DESKTOP: XFCE - LC_TELEPHONE: zh_CN.UTF-8 - XMODIFIERS: @im=fcitx - XDG_SESSION_DESKTOP: xubuntu - XAUTHORITY: /home/luck/.Xauthority - XDG_GREETER_DATA_DIR: /var/lib/lightdm-data/luck - SHELL: /bin/bash - LC_NAME: zh_CN.UTF-8 - QT_ACCESSIBILITY: 1 - GDMSESSION: xubuntu - LC_MEASUREMENT: zh_CN.UTF-8 - GPG_AGENT_INFO: /run/user/1000/gnupg/S.gpg-agent:0:1 - LC_IDENTIFICATION: zh_CN.UTF-8 - QT_IM_MODULE: fcitx - XDG_VTNR: 7 - PWD: /home/luck - XDG_CONFIG_DIRS: /etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg - CLUTTER_IM_MODULE: xim - XDG_DATA_DIRS: /usr/share/xubuntu:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share - LC_NUMERIC: zh_CN.UTF-8 - LC_PAPER: zh_CN.UTF-8 - SESSION_MANAGER: local/luck-VirtualBox:@/tmp/.ICE-unix/908,unix/luck-VirtualBox:/tmp/.ICE-unix/908 - GNOME_KEYRING_CONTROL: /run/user/1000/keyring - SSH_AUTH_SOCK: /run/user/1000/keyring/ssh - PANEL_GDK_CORE_DEVICE_EVENTS: 0 - DISPLAY: :0.0 - GDK_BACKEND: x11 - NO_AT_BRIDGE: 1 - PGADMIN_INT_PORT: 5050 - PGADMIN_INT_KEY: 55e1deac-0ec0-4c30-81d4-a44e052b83d2 - PGADMIN_SERVER_MODE: OFF -------------------------------------------------------- Total spawn time to start the pgAdmin4 server: 0.009 Sec Failed to launch pgAdmin4. Error: Error: spawn /usr/pgadmin4/venv/bin/python3 ENOENT
哈哈,只能按错误继续去看看:
luck@luck-VirtualBox:~/temp$ ls -al /usr/pgadmin4/venv/bin/ |grep python
lrwxrwxrwx 1 root root 7 10月 17 20:25 python -> python3
lrwxrwxrwx 1 root root 18 10月 17 20:25 python3 -> /usr/bin/python3.8
luck@luck-VirtualBox:~/temp$ ls -al /usr/bin/|grep python
-rwxr-xr-x 1 root root 2336 7月 25 2018 dh_python3-ply
lrwxrwxrwx 1 root root 24 11月 3 02:49 pdb3.10 -> ../lib/python3.10/pdb.py
lrwxrwxrwx 1 root root 31 11月 7 14:49 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root 10 11月 7 14:49 python3 -> python3.10
-rwxr-xr-x 1 root root 5876360 11月 3 02:49 python3.10
luck@luck-VirtualBox:~/temp$
对比发现pgadmin4使用了python3.8,而/usr/bin/目录下并没有python3.8(这里注意,不一定是版本python3.8,在我的实机上是python3.9,但在我这台测试机上却是3.8,但解决方法都是相同的。),接下来就是安装多一个版本的python
那么是否可以直接用python3.10来代替python3.8 试下:sudo ln -s /usr/bin/python3.10 /usr/bin/python3.8 后,现重新启动pgAdmin4.发现依然出错!!! 看来只能重新用源码安装一下python3.8,如下:
luck@luck-VirtualBox:~$ mkdir temp
luck@luck-VirtualBox:~$ cd temp/
luck@luck-VirtualBox:~/temp$ ls
luck@luck-VirtualBox:~/temp$ wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
--2022-11-14 19:59:43-- https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
正在解析主机 www.python.org (www.python.org)... 2a04:4e42:12::223, 151.101.76.223
正在连接 www.python.org (www.python.org)|2a04:4e42:12::223|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 23949883 (23M) [application/octet-stream]
正在保存至: ‘Python-3.8.0.tgz’
Python-3.8.0.tgz 100%[==========================================>] 22.84M 143KB/s 用时 2m 1s
2022-11-14 20:01:44 (194 KB/s) - 已保存 ‘Python-3.8.0.tgz’ [23949883/23949883])
luck@luck-VirtualBox:~/temp$
luck@luck-VirtualBox:~/temp$ tar -zxvf Python-3.8.0.tgz
………………
Python-3.8.0/Objects/odictobject.c
Python-3.8.0/Objects/genobject.c
luck@luck-VirtualBox:~/temp$ mv Python-3.8.0 /usr/local/python-3.8.0
mv: 无法将'Python-3.8.0' 移动至'/usr/local/python-3.8.0': 权限不够
luck@luck-VirtualBox:~/temp$ sudo mv Python-3.8.0 /usr/local/python-3.8.0
[sudo] luck 的密码:
对不起,请重试。
[sudo] luck 的密码:
对不起,请重试。
[sudo] luck 的密码:
luck@luck-VirtualBox:~/temp$ cd /usr/local/python-3.8.0/
luck@luck-VirtualBox:/usr/local/python-3.8.0$ ./configure --enable-optimizations
………………
checking for openssl/ssl.h in /usr/local... no
checking for openssl/ssl.h in /usr... no
checking whether compiling and linking against OpenSSL works... no
checking for --with-ssl-default-suites... python
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile
luck@luck-VirtualBox:/usr/local/python-3.8.0$ make
……………………
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
running build_scripts
copying and adjusting /usr/local/python-3.8.0/Tools/scripts/pydoc3 -> build/scripts-3.8
copying and adjusting /usr/local/python-3.8.0/Tools/scripts/idle3 -> build/scripts-3.8
copying and adjusting /usr/local/python-3.8.0/Tools/scripts/2to3 -> build/scripts-3.8
changing mode of build/scripts-3.8/pydoc3 from 664 to 775
changing mode of build/scripts-3.8/idle3 from 664 to 775
changing mode of build/scripts-3.8/2to3 from 664 to 775
renaming build/scripts-3.8/pydoc3 to build/scripts-3.8/pydoc3.8
renaming build/scripts-3.8/idle3 to build/scripts-3.8/idle3.8
renaming build/scripts-3.8/2to3 to build/scripts-3.8/2to3-3.8
gcc -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-use -fprofile-correction -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/_testembed.o ./Programs/_testembed.c
gcc -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o libpython3.8.a -lcrypt -ldl -lm -lm
make[1]: 离开目录“/usr/local/python-3.8.0”
luck@luck-VirtualBox:/usr/local/python-3.8.0$ sudo make install
…………
File "", line 241, in load_module
File "", line 709, in _get_module_code
File "", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [Makefile:1186:install] 错误 1
luck@luck-VirtualBox:/usr/local/python-3.8.0$ 解决上面的错误,就是安装缺少的zlib1g-dev
luck@luck-VirtualBox:/usr/local/python-3.8.0$ sudo apt install zlib1g-dev
luck@luck-VirtualBox:/usr/local/python-3.8.0$ 安装zlib完成后,再次安装python-3.8.0
luck@luck-VirtualBox:/usr/local/python-3.8.0$ sudo make install
…………
(cd /usr/local/bin; ln -s python3.8 python3)
if test "3.8" != "3.8"; then \
rm -f /usr/local/bin/python3.8-config; \
(cd /usr/local/bin; ln -s python3.8-config python3.8-config); \
rm -f /usr/local/lib/pkgconfig/python-3.8.pc; \
(cd /usr/local/lib/pkgconfig; ln -s python-3.8.pc python-3.8.pc); \
rm -f /usr/local/lib/pkgconfig/python-3.8-embed.pc; \
(cd /usr/local/lib/pkgconfig; ln -s python-3.8-embed.pc python-3.8-embed.pc); \
fi
rm -f /usr/local/bin/python3-config
(cd /usr/local/bin; ln -s python3.8-config python3-config)
rm -f /usr/local/lib/pkgconfig/python3.pc
(cd /usr/local/lib/pkgconfig; ln -s python-3.8.pc python3.pc)
rm -f /usr/local/lib/pkgconfig/python3-embed.pc
(cd /usr/local/lib/pkgconfig; ln -s python-3.8-embed.pc python3-embed.pc)
rm -f /usr/local/bin/idle3
(cd /usr/local/bin; ln -s idle3.8 idle3)
rm -f /usr/local/bin/pydoc3
(cd /usr/local/bin; ln -s pydoc3.8 pydoc3)
rm -f /usr/local/bin/2to3
(cd /usr/local/bin; ln -s 2to3-3.8 2to3)
if test "x" != "x" ; then \
rm -f /usr/local/bin/python3-32; \
(cd /usr/local/bin; ln -s python3.8-32 python3-32) \
fi
rm -f /usr/local/share/man/man1/python3.1
(cd /usr/local/share/man/man1; ln -s python3.8.1 python3.1)
if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python -E -m ensurepip \
$ensurepip --root=/ ; \
fi
/tmp/tmpdfsx8osu/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
/tmp/tmpdfsx8osu/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
Looking in links: /tmp/tmpdfsx8osu
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
luck@luck-VirtualBox:/usr/local/python-3.8.0$ 到此python-3.8.0安装完成,测试一下
luck@luck-VirtualBox:/usr/local/python-3.8.0$ ./python
Python 3.8.0 (default, Nov 14 2022, 20:24:11)
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
luck@luck-VirtualBox:/usr/local/python-3.8.0$ 上面提示启动成功,记得退出是按Ctrl+D
接下来很重要,把python-3.8.0软链接到/usr/bin/python3.8
luck@luck-VirtualBox:/usr/local/python-3.8.0$ sudo ln -s /usr/local/python-3.8.0/python /usr/bin/python3.8
测试下启动pgAdmin4-server
luck@luck-VirtualBox:/usr/local/python-3.8.0$ /usr/pgadmin4/venv/bin/python3 -s /usr/pgadmin4/web/pgAdmin4.py
Traceback (most recent call last):
File "/usr/pgadmin4/web/pgAdmin4.py", line 38, in
import config
File "/usr/pgadmin4/web/config.py", line 25, in
from pgadmin.utils import env, IS_WIN, fs_short_path
File "/usr/pgadmin4/web/pgadmin/__init__.py", line 24, in
from flask_socketio import SocketIO
File "/usr/pgadmin4/venv/lib/python3.8/site-packages/flask_socketio/__init__.py", line 21, in
import socketio
File "/usr/pgadmin4/venv/lib/python3.8/site-packages/socketio/__init__.py", line 3, in
from .client import Client
File "/usr/pgadmin4/venv/lib/python3.8/site-packages/socketio/client.py", line 7, in
import engineio
File "/usr/pgadmin4/venv/lib/python3.8/site-packages/engineio/__init__.py", line 3, in
from .client import Client
File "/usr/pgadmin4/venv/lib/python3.8/site-packages/engineio/client.py", line 6, in
import ssl
File "/usr/local/python-3.8.0/Lib/ssl.py", line 98, in
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
luck@luck-VirtualBox:/usr/local/python-3.8.0$
出错了,只能再重新安装“pgadmin4-server”
luck@luck-VirtualBox:/usr/local/python-3.8.0$ sudo apt reinstall pgadmin4-server
这下点启动pgAdmin4终于成功了!!!问题全部解决