Error: No module named psycopg2.extensions

前端 未结 18 1992
感动是毒
感动是毒 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 08:15

    first install apt-get install python-setuptools

    then try easy_install psycopg2

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

    try this:
    sudo pip install -i https://testpypi.python.org/pypi psycopg2==2.7b2
    .. this is especially helpful if you're running into egg error

    on aws ec2 instances if you run into gcc error; try this
    1. sudo yum install gcc python-setuptools python-devel postgresql-devel
    2. sudo su -
    3. sudo pip install psycopg2

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

    I used the extension after only importing psycopg2:

    import psycopg2
    
    ...
    
    psycopg2.extensions.AsIs(anap[i])
    
    0 讨论(0)
  • 2020-12-02 08:17

    you can install gcc for macos from https://github.com/kennethreitz/osx-gcc-installer
    after instalation of gcc you'll be able to install psycopg with easy_install or with pip

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

    I had such problem when trying to run python script as a sudo, while psycopg2 was installed via pip3 to my own user's directory.

    I managed to resolve the issue for myself removing pip3 version, and just installing it via apt:

    pip3 uninstall psycopg2
    sudo apt install python3-psycopg2
    
    0 讨论(0)
  • 2020-12-02 08:19

    For macOS Mojave just run pip install psycopg2-binary. Works fine for me, python version -> Python 3.7.2

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