本文介绍了尝试运行pgAdmin4时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了pgAdmin4附带的postgresql 9.6(使用建议的Linux安装程序),但是出现了一些错误。

I've installed postgresql 9.6 (using suggested linux installer) which comes with pgAdmin4, but getting a few errors.

首先,我必须更改文件夹名称从 pgAdmin 4(请注意多余的空间)到 pgAdmin4,以避免找不到文件错误。

First, I had to change the folder name from "pgAdmin 4" (note the extra space) to "pgAdmin4" to avoid "file not found error".

然后我运行 sudo python pgAdmin4.py 并收到以下错误:

Then I run sudo python pgAdmin4.py and got the following error:

Traceback (most recent call last):
   File "../../pgAdmin4.py", line 24, in <module>
      from pgadmin import create_app
   File "/opt/PostgreSQL/9.6/pgAdmin4/web/pgadmin/__init__.py", line 17, in <module>
      from flask import Flask, abort, request, current_app
ImportError: No module named flask



的模块

我尝试遵循以下相关问题:

-设法将flask安装在virtualenv上。

I tried following this related question:Flask ImportError: No Module Named Flask -- managed to installed flask on virtualenv.

但是后来我开始缺少其他与flask相关的模块:flask_babel,flask_login, flask_security。我使用pip安装了所有这些组件,但是随后我丢失了模块 htmlmin.minify ,但似乎无法安装。

But then I started getting other flask related modules that are missing: flask_babel, flask_login, flask_security. I installed all of them using pip, but then I got an error on missing module htmlmin.minify which I can't seems to able to install.

Traceback (most recent call last):
   File "../pgAdmin4.py", line 24, in <module>
      from pgadmin import create_app
   File "/opt/PostgreSQL/9.6/pgAdmin4/web/pgadmin/__init__.py", line 23, in <module>
      from htmlmin.minify import html_minify
ImportError: No module named htmlmin.minify

我还将PYTHONPATH导出到了烧瓶上的一个,如,仍然出现相同的错误。

I also exported PYTHONPATH to the one on flask, as described here, still getting the same error.

因此,任何人都知道如何使pgAdmin4正常工作

So, anyone have an idea how to make pgAdmin4 work on ubuntu environemt?

推荐答案

根据。

通过运行以下命令安装virtualenv:

Install the virtualenv by running:

sudo apt-get install virtualenv

您还需要安装以下两个库:

You also need to install these 2 libraries:

sudo apt-get install libpq-dev python-dev

然后:

cd ~/bin/
virtualenv pgadmin4

我更喜欢使用〜/ bin / 安装应用程序的目录。

I prefer to use the ~/bin/ directory for installing applications.

然后下载 pgadmin4-1.1-py2-none-any.whl pgadmin4-1.1-py3-none-any.whl 取决于您使用的python版本。对于此示例,我们使用python 2.7。

Then you download the pgadmin4-1.1-py2-none-any.whl or pgadmin4-1.1-py3-none-any.whl depending on the python version you use. For this example we use python 2.7.

您下载pgadmin4:

You download pgadmin4:

wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl

激活虚拟环境:

. ~/bin/pgadmin4/bin/activate

之后,您将看到(终端中的pgadmin4)

在pgadmin4内部运行:

Inside of pgadmin4 run:

pip install ./pgadmin4-1.1-py2-none-any.whl

之后,您必须能够运行pgadmin4:

After that you must be able to run pgadmin4:

python ~/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

为了简化运行过程,您可以创建一个别名。例如,在Ubuntu 16.04 LTS中,在〜/ .bash_aliases 文件中添加别名:

In order to make the running process a bit easier you can create an alias. For instance, in Ubuntu 16.04 LTS, add alias in the ~/.bash_aliases file:

alias pgadmin4='. /home/your_username/bin/pgadmin4/bin/activate; /home/your_username/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py'

您的用户名替换为您的真实用户名。

Where your_username should be replaced by your real user name.

然后授予执行权限,例如, 764 pgAdmin4.py 文件的位置:

Then give execute permission, for example, 764 to the pgAdmin4.py file in:

/home/your_username/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

此外,您还需要编辑 pgAdmin4.py 文件,并将此行添加到最上方:

Also you need to edit the pgAdmin4.py file and add this line in the very top:

#!/home/your_username/bin/pgadmin4/bin/python

其中您的用户名是您的真实用户名。

where your_username is your real user name.

确保使用所需版本的python运行应用程序并包括所有必需的依赖项,以便运行 pgadmin4

This will make sure that you run the application using the required version of python and include all necessary dependencies in order to run pgadmin4.

然后运行。 〜/ .bashrc 来应用更改。

所以现在您可以打开终端并只需键入 pgadmin4 以便运行它。

So now you can open your terminal and simply type pgadmin4 in order to run it.

打开浏览器并指向:

http://127.0.0.1:5050

还有一件事注意-如果需要在桌面模式下运行 pgadmin4 ,则需要在以下方式中将 SERVER_MODE 更改为False:

One more thing to note - if you need to run pgadmin4 in desktop mode you need to change SERVER_MODE to False in:

/home/your_username/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/config.py

否则,当您访问localhost:5050时,它将要求您输入登录名和密码。

Otherwise when you visit localhost:5050 it will ask you for your login and password.

希望这会有所帮助。

这篇关于尝试运行pgAdmin4时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-07 11:33