Error: No module named psycopg2.extensions

前端 未结 18 1990
感动是毒
感动是毒 2020-12-02 07:35

I am trying to set up a PostgreSQL database for my django project, which I believe I have done now thanks to the replies to my last question Problems setting up a postgreSQL

相关标签:
18条回答
  • 2020-12-02 07:54

    It seems that you need gcc-4.0, and it would be helpful to specify your OS type and version.

    Maybe this question will help you a bit: Installing GCC to Mac OS X Leopard without installing Xcode

    Update

    I'm a Windows user, so I can't test your setup, but a quick google pointed to some more links:

    • http://hardlifeofapo.com/psycopg2-and-postgresql-9-1-on-snow-leopard/
    • Cannot install psycopg2 on OSX 10.6.7 with XCode4
    0 讨论(0)
  • 2020-12-02 07:57

    This one worked for me

    python manage.py migrate

    0 讨论(0)
  • 2020-12-02 08:01

    This is what helped me on Ubuntu if your python installed from Ubuntu installer. I did this after unsuccessfully trying 'apt-get install' and 'pip install':

    In terminal:

    sudo synaptic
    

    then in synaptic searchfield write

    psycopg2
    

    choose

    python-psycopg2
    

    mark it for installation using mouse right-click and push 'apply'. Of course, if you don't have installed synaptic, then first do:

    sudo apt-get install synaptic
    
    0 讨论(0)
  • 2020-12-02 08:01

    In python 3.4, while in a virtual environment, make sure you have the build dependencies first:

    sudo apt-get build-dep python3-psycopg2
    

    Then install it:

    pip install psycopg2 
    
    0 讨论(0)
  • 2020-12-02 08:02
    pip3 install django-psycopg2-extension
    

    I know i am late and there's lot of answers up here which also solves the problem. But today i also faced this problem and none of this helps me. Then i found the above magical command which solves my problem :-P . so i am posting this as it might be case for you too.
    Happy coding.

    0 讨论(0)
  • 2020-12-02 08:04

    I encountered the No module named psycopg2.extensions error when trying to run pip2 install psycopg2 on a Mac running Mavericks (10.9). I don't think my stack trace included a message about gcc, and it also included a hint:

    Error: pg_config executable not found.
    
    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.
    

    I looked for the pg_config file in my Postgres install and added the folder containing it to my path: /Applications/Postgres.app/Contents/Versions/9.4/bin. Your path may be different, especially if you have a different version of Postgres installed - I would just poke around until you find the bin/ folder. After doing this, the installation worked.

    0 讨论(0)
提交回复
热议问题