-2

I'm trying to install pgAdmin4 from its source code on WSL 2 (running Ubuntu 22.04 (Jammy Jellyfish) distribution), and I've been following the steps in the README document in pgAdmin4's GitHub repository.

To configure the Python environment, I've successfully completed steps 1 to 5. Now, I'm trying to run the initial setup of the database configuration using:

(venv) hallixon@PC:~/pgadmin4$ sudo python3 web/setup.py

or

(venv) hallixon@PC:~/pgadmin4$ sudo python3 web/pgAdmin4.py

But both commands throw the following error:

Traceback (most recent call last):
  File "/home/hallixon/pgadmin4/web/pgAdmin4.py", line 49, in <module>
    import config
  File "/home/hallixon/pgadmin4/web/config.py", line 32, in <module>
    from pgadmin.utils import env, IS_WIN, fs_short_path
  File "/home/hallixon/pgadmin4/web/pgadmin/__init__.py", line 24, in <module>
    from flask import Flask, abort, request, current_app, session, url_for
ModuleNotFoundError: No module named 'flask'

Meanwhile, running the following script to show the list of modules installed in the current virtual environment (venv) returns flask in the list.

>>> help('modules')

A portion of the list of modules returned by running the script above.

Please, how can I solve this? I'd also appreciate links to articles showing how to install pgAdmin4 from its source code on WSL 2 (Ubuntu distribution, preferably).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Look at [How do I use sudo with python inside virtualenvironment](https://stackoverflow.com/q/61715573/10171966) and see if that solves your problem. – SebDieBln Aug 20 '23 at 23:13
  • Does [Unable to import a module that is definitely installed](https://stackoverflow.com/questions/14295680/) answer your question? – Karl Knechtel Aug 30 '23 at 16:12
  • Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*) and [do the right thing](https://stackoverflow.com/posts/76941505/edit) (it covers answers as well). Thanks in advance. – Peter Mortensen Sep 02 '23 at 13:49

1 Answers1

-1

You should try running the script without sudo. With sudo, the Python interpreter might not be able to find the packages installed on the virtual environment.

Tito
  • 289
  • 8
  • While it's true that `sudo` shouldn't be used, the relationship to the problem is likely vague at best. The real problem is that *there is more than one Python interpreter* (we know this because, at minimum, there is the virtual environment denoted by `(venv)` in OP's prompt, and the base installation that it was created from); it is necessary to use the same interpreter for which the packages were actually installed. – Karl Knechtel Aug 30 '23 at 16:13