【发布时间】:2018-01-13 01:32:01
【问题描述】:
我在使用来自https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-python 的以下代码行时遇到问题
import os
import psycopg2
import urlparse
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse(os.environ["DATABASE_URL"])
conn = psycopg2.connect(
database=url.path[1:],
user=url.username,
password=url.password,
host=url.hostname,
port=url.port
)
我正在使用 Python 3.6.2
在我看到的 Heroku 日志中:
ModuleNotFoundError: 没有名为“urlparse”的模块
任何帮助将不胜感激!
【问题讨论】:
-
AWS Lambda 上的 Python 也将我带到了这里!
标签: python postgresql heroku flask