Psycopg2 未正确链接,包含错误或其他什么?

发布于 2024-12-02 22:17:40 字数 2680 浏览 2 评论 0原文

我在让 Django 与我的网络托管提供商上的 postgresl 数据库一起使用时遇到了麻烦。

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

在遇到了很多包含问题(尤其是在哪里放置所有包含内容)之后,我已经取得了很大的进展,Django 的东西主要在工作,除了与我的 postgresql 数据库建立连接之外。我已经将 Django 和 psycopg2 “安装”(即解压并放入我的 $PYTHONPATH)到我的 ~/python-modules/ 文件夹中。

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

> 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 版本或其他什么?

I'm having trouble in getting Django work with a postgresl database on my webhosting provider.

My situation is as follows: I have an account on my webhosting provider, I do not have root-priviledges or the ability to install anything except locally in my home folder. I'm running Django through fcgi (because that is the only way for me afaik). I'm trying to convert my website to use Django. The webhosting server is running 64bit (debian or something custom I think).

After a LOT of trouble with includes (and especially where to put all the includes) I've gotten pretty far and Django stuff is mainly working, except making a connection to my postgresql database. I have "installed" (ie. untarred and put in my $PYTHONPATH) Django and psycopg2 to my ~/python-modules/ folder.

But for some reason I'm getting this when trying to do 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

I currently have no idea why it can't find a basic python datatype. Psycopg2 linked to wrong python version or something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅渡 2024-12-09 22:17:40

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

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

yes, it looks like a versioning problem. more exactly the python running is lower than the one psycopg2 is built for (2.6)

you can check the python version by running 'python -V' or calling 'sys.version_info', but if your distribution is a debian stable then the default python is 2.5

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文