title: psycopg2 installed on M1 running MacOS Big Sur, but unable to run local server
body: <p>I have the new (2021) Macbook Air running the Apple M1 chip. I have set up my django application, which uses postgresql, and I have created a virtualenv running Python 3.9.2. Have installed Python directly from the macOS 64-bit universal2 installer on python.org. After much difficulty, I was finally able to install psycopg2 using:</p>
  <pre><code>env LDFLAGS=&quot;-L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/readline/lib&quot; pip3 --no-cache install psycopg2-binary==2.8.6
  </code></pre>
  <p>I am able to SSH into my PostgreSQL DB, but when I run python manage.py runserver, I get the following error (abridged due to length).</p>
  <pre><code>File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/contrib
  /auth/models.py&quot;, line 2, in &lt;module&gt;
      from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/contrib
  /auth/base_user.py&quot;, line 47, in &lt;module&gt;
      class AbstractBaseUser(models.Model):
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/mode
  ls/base.py&quot;, line 121, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/mode
  ls/base.py&quot;, line 325, in add_to_class
      value.contribute_to_class(cls, name)
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/mode
  ls/options.py&quot;, line 208, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/__in
  it__.py&quot;, line 28, in __getattr__
      return getattr(connections[DEFAULT_DB_ALIAS], item)
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/util
  s.py&quot;, line 207, in __getitem__
      backend = load_backend(db['ENGINE'])
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/util
  s.py&quot;, line 111, in load_backend
      return import_module('%s.base' % backend_name)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__
  init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;/Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/django/db/back
  ends/postgresql/base.py&quot;, line 29, in &lt;module&gt;
      raise ImproperlyConfigured(&quot;Error loading psycopg2 module: %s&quot; % e)
  django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/
  Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/psycopg2/_psycopg.cpyth
  on-39-darwin.so, 2): Symbol not found: _PQbackendPID
    Referenced from: /Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/psy
  copg2/_psycopg.cpython-39-darwin.so
    Expected in: flat namespace
   in /Users/seb/.virtualenvs/onefabric/lib/python3.9/site-packages/psycopg2/_psycopg.
  cpython-39-darwin.so
  </code></pre>
  <p>How can I resolve this and run my local server?</p>