尝试在MacOS 10.14.4上使用pip 19.1安装psycopg2会返回以下冗长的错误消息。我知道有些警告与gcc有关,但是鉴于实际的错误消息,我无法找到任何潜在问题的线索。
我尝试了以下操作,但没有任何运气:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages(是,我已经安装了某个文件,并且可以正常工作,不确定为什么要卸载)在pip和psycopg2周围似乎存在很多问题,但是我在Stackoverflow上发现的任何问题都没有显示类似的错误消息,也没有提供任何建议的修复程序。非常感谢任何指向潜在修复程序的提示!
pip install psycopg2
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/23/7e/93c325482c328619870b6cd09370f6dbe1148283daca65115cd63642e60f/psycopg2-2.8.2.tar.gz
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/y4/3pcgz9d54zj29hfq1lmlxpk80000gn/T/pip-install-ci93cz6u/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/y4/3pcgz9d54zj29hfq1lmlxpk80000gn/T/pip-record-ztnpuu7u/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/psycopg2
copying lib/_json.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
copying lib/extras.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
copying lib/compat.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2
copying lib/errorcodes.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2 …Run Code Online (Sandbox Code Playgroud) 在我的网络应用程序中,我有地点和各自的开放时间。OpeningHours 模型如下所示:
class OpeningHours(models.Model):
location = models.ForeignKey(
Location, related_name='hours', on_delete=models.CASCADE)
weekday = models.PositiveSmallIntegerField(choices=WEEKDAYS, unique=True)
from_hour = models.PositiveSmallIntegerField(choices=HOUR_OF_DAY_12)
to_hour = models.PositiveSmallIntegerField(choices=HOUR_OF_DAY_12)
class Meta:
ordering = ('weekday', 'from_hour')
unique_together = ('weekday', 'from_hour', 'to_hour')
def get_weekday_display(self):
return WEEKDAYS[self.weekday][1]
def get_hours_display(self):
return '{} - {}'.format(HOUR_OF_DAY_12[self.from_hour][1], HOUR_OF_DAY_12[self.to_hour][1])
def get_start_hour_display(self):
return HOUR_OF_DAY_12[self.from_hour][1]
def get_end_hour_display(self):
return HOUR_OF_DAY_12[self.to_hour][1]
def __str__(self):
return '{}: {} - {}'.format(self.get_weekday_display(),
HOUR_OF_DAY_12[self.from_hour][1], HOUR_OF_DAY_12[self.to_hour][1])
Run Code Online (Sandbox Code Playgroud)
我正在尝试测试一个模型,类似于我在应用程序中成功测试其他模型的方式:
class OpeningHours(TestCase):
def create_opening_hours(self, weekday=1, from_hour=12, to_hour=15):
self.location = create_location(self)
return OpeningHours.objects.create(location=self.location, weekday=weekday, from_hour=from_hour, to_hour=to_hour)
def test_opening_hours(self):
oh = self.create_opening_hours() …Run Code Online (Sandbox Code Playgroud)