0

Machine: Mac OSX Python Version: 3.X, specifically 3.7.3

I was looking at the psycopg2 documentation, it said it was Python3 friendly. https://pypi.org/project/psycopg2/

It was saying that all i would need to do is to do something akin to: pip install psycopg2 but when I do it, setup.py install will give an error.

ERROR: Command "/usr/local/bin/python3.7 -u -c 'import setuptools, tokenize;file='"'"'/private/var/folders/r3/lv90w0yx6xq9t2p4qgb7yb1r0000gn/T/pip-install-66v9kpqs/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/r3/lv90w0yx6xq9t2p4qgb7yb1r0000gn/T/pip-record-8anshmva/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/r3/lv90w0yx6xq9t2p4qgb7yb1r0000gn/T/pip-install-66v9kpqs/psycopg2/

I was trying to figure out how to progress with this, in order to have psycopg2 be easily used within Python3.

I dont think i should be downloading the source and building it and likewise their website says I shouldnt use binaries for production.

The following gives the insight to use the binary on my mac, but not to use it for production. I can't install Psycopg2 with Python3 on Mac. I've installed Python3 and pip3 This gives me one caveat, I am not sure what my prod server will be. Usually it is unix, but i was thinking "wait, does mac have a prod server? How would i do it for there then?"

It wanted me to just implement: pip3 install psycopg2-binary but like what the psycopg2 website said, that should not be a prod solution. Me personally, I dont like writing custom scripts for custom OS. I think that to give the best experience, the application should be cross-platform compatible, ESPECIALLY since this is python.

I cant seem to figure it out, has anyone figured out how to do this?

EDIT: Pip3 install seems to cause an error with GCC when compiling. The issue I saw was as follows:

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1

I tested it and gcc is in my path, so it seems that it doesnt know what lssl is. why would that not be a valid statement. I figured pip3 would have tested against this?

Fallenreaper
  • 10,222
  • 12
  • 66
  • 129
  • I was not able to reproduce the error with a mac book running on OSX 10.13.6, python 3.7.2. I did pip install psycopg2 and the installation was successful. – Damien Baldy Jul 17 '19 at 21:06
  • 1
    Why would using pip3 not be a "prod solution"? – Daniel Roseman Jul 17 '19 at 21:12
  • no, its not the use of pip3 vs pip, as much as using the `psycopg2-binary`. That is weird that you got it to work. I am on 10.14.5. I am going to edit the question with the error log – Fallenreaper Jul 18 '19 at 13:04
  • `ld: library not found for -lssl` -> `brew install openssl`. There's nothing wrong with Python, you're missing libraries to compile C extensions in the `psycopg2` package. – hoefling Jul 18 '19 at 17:21
  • odd. I did `brew install openssl` and it said it was already installed. – Fallenreaper Jul 18 '19 at 20:12
  • Then you have an issue with your current MacOS version and Homebrew, most probably due to an upgrade from High Sierra to Mojave; [Linking not working in homebrew's cmake since Mojave](https://stackoverflow.com/questions/54068035/linking-not-working-in-homebrews-cmake-since-mojave) might be helpful to start with. I'd say XY problem, not related to Python... – hoefling Jul 19 '19 at 13:38
  • Esp. [this answer](https://stackoverflow.com/a/57014480/2650249) in the question should provide you with some helpful info. I don't work with MacOS since Mojave anymore so can't say for sure whether a perm change is a good idea, but the flag adjustment looks promising, smth like `LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" pip install psycopg2 --no-binary=psycopg2` – hoefling Jul 19 '19 at 13:43

0 Answers0