title: psycopg2 - ImportError: DLL load failed while importing _psycopg: The operating system cannot run %1
body: <p>I installed psycopg2 using conda on Windows 10.</p>
  <p><a href="https://anaconda.org/anaconda/psycopg2" rel="noreferrer">https://anaconda.org/anaconda/psycopg2</a></p>
  <p>I did it in a clean new conda environment (named wr).</p>
  <p>I then tried to run this sample app but I am getting this error (see below).
  I have no idea what I might be doing wrong because it was all straightforward and I did it in a clean way.</p>
  <p>Any ideas how to solve this?</p>
  <pre><code>import psycopg2
  try:
      connection = psycopg2.connect(user = &quot;***&quot;,
                                    password = &quot;***&quot;,
                                    host = &quot;***&quot;,
                                    port = &quot;5432&quot;,
                                    database = &quot;***&quot;)
  
  
      cursor = connection.cursor()
      # Print PostgreSQL Connection properties
      print ( connection.get_dsn_parameters(),&quot;\n&quot;)
  
      # Print PostgreSQL version
      cursor.execute(&quot;SELECT version();&quot;)
      record = cursor.fetchone()
      print(&quot;You are connected to - &quot;, record,&quot;\n&quot;)
  
  except (Exception, psycopg2.Error) as error :
      print (&quot;Error while connecting to PostgreSQL&quot;, error)
  finally:
      #closing database connection.
          if(connection):
              cursor.close()
              connection.close()
              print(&quot;PostgreSQL connection is closed&quot;)
  </code></pre>
  <p>Error in VS code:</p>
  <pre><code>PS C:\Work\WRR\git\tools\JTunnelTestApp&gt;  cd 'c:\Work\WRR\git\tools\JTunnelTestApp'; &amp; 'C:\Programs\Anaconda3\envs\wr\python.exe' 'c:\Users\petrop01\.vscode\extensions\ms-python.python-2020.9.114305\pythonFiles\lib\python\debugpy\launcher' '56143' '--' 'c:\Work\WRR\git\tools\JTunnelTestApp\main.py'
  Traceback (most recent call last):
    File &quot;c:\Work\WRR\git\tools\JTunnelTestApp\main.py&quot;, line 1, in &lt;module&gt;
      import psycopg2
    File &quot;C:\Programs\Anaconda3\envs\wr\lib\site-packages\psycopg2\__init__.py&quot;, line 51, in &lt;module&gt;
      from psycopg2._psycopg import (                     # noqa
  ImportError: DLL load failed while importing _psycopg: The operating system cannot run %1.
  PS C:\Work\WRR\git\tools\JTunnelTestApp&gt;
  </code></pre>
  <p><strong>EDIT</strong>: Seems they had a bug open for this 2 years ago and they just closed it, ignoring it completely.</p>
  <p><a href="https://github.com/psycopg/psycopg2/issues/734" rel="noreferrer">https://github.com/psycopg/psycopg2/issues/734</a></p>