【问题标题】:Psycopg2 not linked correctly, wrong includes or something?Psycopg2 链接不正确,包含错误还是什么?
【发布时间】:2011-11-11 06:08:15
【问题描述】:

我无法让 Django 使用我的虚拟主机提供商上的 postgresl 数据库。

我的情况如下:我在我的虚拟主机提供商上有一个帐户,我没有 root 权限,也没有能力在我的主文件夹中本地安装任何东西。我正在通过 fcgi 运行 Django(因为这是我 afaik 的唯一方法)。我正在尝试将我的网站转换为使用 Django。虚拟主机服务器运行 64 位(我认为是 debian 或自定义的)。

在包含很多麻烦之后(尤其是在哪里放置所有包含),我已经走了很远,Django 的东西主要工作,除了连接到我的 postgresql 数据库。我已经“安装”(即解压缩并放入我的 $PYTHONPATH)Django 和 psycopg2 到我的 ~/python-modules/ 文件夹中。

但由于某种原因,我在尝试 python manage.py syncdb 时遇到了这个问题:

> Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/home/users/username/python-modules/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/home/users/username/python-modules/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/users/username/python-modules/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/users/username/python-modules/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/users/username/python-modules/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/users/username/python-modules/django/core/management/commands/syncdb.py", line 7, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "/home/users/username/python-modules/django/core/management/sql.py", line 6, in <module>
    from django.db import models
  File "/home/users/username/python-modules/django/db/__init__.py", line 78, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/home/users/username/python-modules/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/users/username/python-modules/django/db/utils.py", line 33, in load_backend
    return import_module('.base', backend_name)
  File "/home/users/username/python-modules/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/users/username/python-modules/django/db/backends/postgresql_psycopg2/base.py", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: /home/users/username/python-modules/psycopg2-2.4.2/build/lib.linux-x86_64-2.6/psycopg2/_psycopg.so: undefined symbol: PyByteArray_Type

我目前不知道为什么它找不到基本的 python 数据类型。 Psycopg2 链接到错误的 python 版本或什么?

【问题讨论】:

    标签: python django postgresql psycopg2


    【解决方案1】:

    是的,它看起来像是版本控制问题。更确切地说,运行的 python 比为 (2.6) 构建的 psycopg2 低

    您可以通过运行“python -V”或调用“sys.version_info”来检查 python 版本,但如果您的发行版是 debian stable 则默认 python 为 2.5

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-21
      • 1970-01-01
      • 1970-01-01
      • 2019-02-13
      • 1970-01-01
      • 1970-01-01
      • 2012-08-02
      • 1970-01-01
      相关资源
      最近更新 更多