centos virtualenv中没有名为“flask”的模块

vyswwuz2  于 2023-06-05  发布在  其他
关注(0)|答案(1)|浏览(201)

我在Centos 8中运行pgAdmin4没有问题。我升级到pgAdmin4 7.11,现在它不再工作了。这就是错误:

ModuleNotFoundError: No module named 'flask'

Flask安装在virtualenv中:

# pwd
/usr/pgadmin4/venv/lib/python/site-packages

# ll -d flask*
drwxrwxr-x. 3 root root  4096 May 29 12:14 flask
drwxrwxr-x. 2 root root    46 May 29 12:14 flask_babel
drwxrwxr-x. 2 root root    98 May 29 12:14 flask_babel-3.1.0.dist-info
drwxrwxr-x. 2 root root    69 May 29 12:14 flask_compress
drwxrwxr-x. 2 root root    43 May 29 12:14 flask_gravatar
drwxrwxr-x. 2 root root   159 May 29 12:14 flask_login
-rw-rw-r--. 1 root root 17950 May  3 11:10 flask_mail.py
drwxrwxr-x. 3 root root    56 May 29 12:14 flask_migrate
drwxrwxr-x. 2 root root    44 May 29 12:14 flask_paranoid
-rw-rw-r--. 1 root root 13860 May  3 11:10 flask_principal.py
drwxrwxr-x. 6 root root  4096 May 29 12:14 flask_security
drwxrwxr-x. 2 root root    67 May 29 12:14 flask_socketio
drwxrwxr-x. 2 root root  4096 May 29 12:14 flask_sqlalchemy
drwxrwxr-x. 3 root root   120 May 29 12:14 flask_wtf

# ll -d Flask*
drwxrwxr-x. 2 root root 147 May 29 12:14 Flask-2.2.5.dist-info
drwxrwxr-x. 2 root root 123 May 29 12:14 Flask_Compress-1.13.dist-info
drwxrwxr-x. 2 root root 148 May 29 12:14 Flask_Gravatar-0.5.0.dist-info
drwxrwxr-x. 2 root root 119 May 29 12:14 Flask_Login-0.6.2.dist-info
drwxrwxr-x. 2 root root 119 May 29 12:14 Flask_Mail-0.9.1.dist-info
drwxrwxr-x. 2 root root 119 May 29 12:14 Flask_Migrate-4.0.4.dist-info
drwxrwxr-x. 2 root root 119 May 29 12:14 Flask_Paranoid-0.3.0.dist-info
drwxrwxr-x. 2 root root  87 May 29 12:14 Flask_Principal-0.4.0.dist-info
drwxrwxr-x. 2 root root 134 May 29 12:14 Flask_Security_Too-5.1.2.dist-info
drwxrwxr-x. 2 root root 119 May 29 12:14 Flask_SocketIO-5.3.4.dist-info
drwxrwxr-x. 3 root root  99 May 29 12:14 Flask_SQLAlchemy-3.0.3.dist-info
drwxrwxr-x. 2 root root 123 May 29 12:14 Flask_WTF-1.1.1.dist-info

$PYTHONPATH为空:

# source bin/activate
(venv) [root@ck venv]# echo $PYTHONPATH

virtualenv正在使用自己的python,正如预期的那样:

(venv) [root@ck venv]# which python
/usr/pgadmin4/venv/bin/python

如果我从virtualenv python interactive中导入flask,它可以工作:

(venv) [root@ck venv]# python
Python 3.9.16 (main, Jan 17 2023, 18:53:15) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>
a6b3iqyw

a6b3iqyw1#

我发现问题了。wsgi版本是用与virtualenv中的版本不同的早期Python版本构建的。我删除了wsgi,并在virtualenv中安装了一个相同Python版本的wsgi,现在它可以工作了。

相关问题