Search code examples
python-2.7psycopg2linux-mintpgadmin-4

Setting up PGAdmin4 - Psycopg Error


I have installed PostgreSQL 9.6 and I am trying to setup PGAdmin4. I am using Linux Mint 17.3. To set it up, I ran the following commands:

1) I made sure to run sudo apt-get install python-dev and sudo apt-get install libpq-dev

1) In my home directory, I ran the command: virtualenv pgadmin4

2) I changed into the directory: cd pgadmin4

3) I activated my virtual environment: source bin/activate

4) I ran the following command to retrieve the Python wheel: wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl

5) I installed pgadmin4 into my virtual environment, along with all of its dependencies: pip install pgadmin4-1.1-py2-none-any.whl

6) I edited config_local.py to include SERVER_MODE = False

7) I ran the command: python ./lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

I then got the following traceback:

Traceback (most recent call last):
  File "./lib/python2.7/site-packages/pgadmin4/pgAdmin4.py", line 46, in <module>
    app = create_app()
  File "/home/samuel/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/__init__.py", line 241, in create_app
    driver.init_app(app)
  File "/home/samuel/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/utils/driver/__init__.py", line 40, in init_app
    DriverRegistry.load_drivers()
  File "/home/samuel/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/utils/driver/registry.py", line 88, in load_drivers
    module = import_module(module_name)
  File "/home/samuel/pgadmin4/lib/python2.7/site-packages/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/samuel/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/utils/driver/psycopg2/__init__.py", line 23, in <module>
    import psycopg2
  File "/home/samuel/pgadmin4/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /home/samuel/pgadmin4/lib/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: PyMemoryView_Type

I've been researching a solution to this issue for a while, but I haven't been able to find anything with my google searches. Any idea what I need to do to get pgadmin4 running?


Solution

  • I figured this out. My system by default is configured to use Python 2.6, thus I was using the wrong interpreter.

    The solution is to run:

    python2.7 ./lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
    

    instead of:

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