[英]Trouble with pip install psycopg2
Trying to learn Django.尝试学习 Django。 Followed the tutorial and created my virtual environment.
按照教程创建了我的虚拟环境。 Now I'm trying to install psycopg2.
现在我正在尝试安装 psycopg2。 I can install psycopg2-binary, but I've been told for "psycopg2-binary is good for development and testing but it is advised to use psycopg2 for production".
我可以安装 psycopg2-binary,但有人告诉我“psycopg2-binary 有利于开发和测试,但建议将 psycopg2 用于生产”。 So I'd like to figure this out.
所以我想弄清楚这一点。
In my venv I'm running pip install psycopg2 it starts with this:在我的 venv 中,我正在运行 pip install psycopg2 它以此开头:
Collecting psycopg2
Using cached psycopg2-2.8.6.tar.gz (383 kB)
Using legacy 'setup.py install' for psycopg2, since package 'wheel' is not installed.
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
Then gives this error:然后给出这个错误:
ERROR: Command errored out with exit status 1:
command: /Users/Me/Documents/Learn/PythonDjango/dev/project/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hf/9bs1zgkx5pj9gt84snhwrq780000gn/T/pip-install-atdy12xg/psycopg2_cd32e59009264d2bbf87b0a9def98b4e/setup.py'"'"'; __file__='"'"'/private/var/folders/hf/9bs1zgkx5pj9gt84snhwrq780000gn/T/pip-install-atdy12xg/psycopg2_cd32e59009264d2bbf87b0a9def98b4e/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'"'"'))' install --record /private/var/folders/hf/9bs1zgkx5pj9gt84snhwrq780000gn/T/pip-record-30vttiiv/install-record.txt --single-version-externally-managed --compile --install-headers /Users/me/Documents/Learn/PythonDjango/dev/project/venv/include/site/python3.9/psycopg2
cwd: /private/var/folders/hf/9bs1zgkx5pj9gt84snhwrq780000gn/T/pip-install-atdy12xg/psycopg2_cd32e59009264d2bbf87b0a9def98b4e/
Then it's a long list of generated warnings.然后是一长串生成的警告。 I've done some research and I've been unable to get it to work.
我做了一些研究,但我无法让它发挥作用。 Running Python 3.9.0 on macOS Big Sur 11.2.1
在 macOS Big Sur 11.2.1 上运行 Python 3.9.0
on Big Sur (MacOS) I was finally able to install this tonight using the following (had the same issues as you):在 Big Sur (MacOS) 上,我终于能够在今晚使用以下方法安装它(和你有同样的问题):
brew install openssl
(install homebrew before this command if you don't have it already) (如果您还没有,请在此命令之前安装自制软件)
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
then finally.......然后最后.......
pip3 install psycopg2
pip install psycopg
it worked for me. pip install psycopg
它对我有用。 don't mention version ie("pip install psycopg2").不要提及版本 ie("pip install psycopg2")。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.