我在 Windows 上使用 python django,并尝试部署到 heroku。当我尝试使用 pip 安装 psycopg2 时,
pip install psycopg2
我得到错误:
找不到vcvarsall.bat
然后我发现我需要安装visual studio 2008(或者)我可以直接下载并安装编译版本,所以从这个链接下载:
http ://www.lfd.uci.edu /~gohlke/pythonlibs/
我下载的文件名:psycopg2-2.4.5.win32-py2.7.exe
即使在安装后我收到错误:没有名为 psycopg2.extensions 的模块
那么,我还应该做什么呢?
D:\mycode\python\mysite>heroku run python manage.py syncdb
Running python manage.py syncdb attached to terminal... up, run.1
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/venv/lib/python2.7/site- packages/django/core/management/__i
nit__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py"
, line 35, in import_module
__import__(name)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/sql
.py", line 6, in <module>
from django.db import models
File "/app/.heroku/venv/lib/python2.7/site- packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line24, in load_backend
return import_module('.base', backend_name)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py"
, line 35, in import_module
__import__(name)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 13, in <module>
from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation
File "/app/.heroku/venv/lib/python2.7/site- packages/django/db/backends/postgre
sql_psycopg2/creation.py", line 1, in <module>
import psycopg2.extensions
ImportError: No module named psycopg2.extensions
D:\mycode\python\mysite>
虽然通过 pip 和 easy_install 安装 psycopg2,但 installdidnt 工作,因为我收到此错误:无法找到带有一些 msg 的 vcvarsall.bat:没有预先包含与“doc\src_build”匹配的目录
谢谢