简体   繁体   中英

Installing psycopg2 on M1

First of all, I know there are many similar questions already out there on SO. But none of them are working for me .

I'm using a 2020 Macbook Air with an Apple M1 chip installed. I need psycopg2 to run my postgres Django database. psycopg2 just isn't installing, how many ever times I install lipq or openssl via homebrew or installing only psycopg2-binary : nothing's working .

I'm doing all of this inside my conda virtual environment, if that's going to help you, using PIP.

Whenever I do pip install psycopg2 , PIP just cycles through all the available versions and tries to install it.

It keeps saying this

ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/opt/python@3.9/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_54b9167ec8544ee0844b2f85085d9e31/setup.py'"'"'; __file__='"'"'/private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_54b9167ec8544ee0844b2f85085d9e31/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-pip-egg-info-8vyyh57i
       cwd: /private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_54b9167ec8544ee0844b2f85085d9e31/
  Complete output (6 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_54b9167ec8544ee0844b2f85085d9e31/setup.py", line 245
      except Warning, w:
                    ^
  SyntaxError: invalid syntax

At the last iteration

ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/opt/python@3.9/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_25faf90bbbc84c69ace950d40ca94f61/setup.py'"'"'; __file__='"'"'/private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_25faf90bbbc84c69ace950d40ca94f61/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-pip-egg-info-zyskdyv8
       cwd: /private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_25faf90bbbc84c69ace950d40ca94f61/
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/d_/gv1n_nvn2f99dqd7kf7vc3xw0000gn/T/pip-install-389xqqoi/psycopg2_25faf90bbbc84c69ace950d40ca94f61/setup.py", line 50, in <module>
      import ConfigParser
  ModuleNotFoundError: No module named 'ConfigParser'

And then it says

WARNING: Discarding https://files.pythonhosted.org/packages/19/79/35c7596bab4456f3610c12ec542a94d51c6781ced587d1d85127210b879b/psycopg2-2.0.10.tar.gz#sha256=e40cc04b43849085725076ae134bfef9e3b087f6dd7c964aeeb930e2f0bc14ab (from https://pypi.org/simple/psycopg2/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement psycopg2 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3)
ERROR: No matching distribution found for psycopg2

Do you know what might help me?

pip install pyscopg2 in the Rosetta terminal was what I needed to get it up and running.

I was using Visual Studio Code's terminal until now, and finally it hit me: My VsCode doesn't run Rosetta.

Well that's all good, everything's working, and thank you @YevgeniyKosmak for helping me out!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM