在 Snow Leopard 上安装 PostgreSQL 和 pyscopg2

发布于 2024-08-15 20:34:50 字数 1417 浏览 8 评论 0原文

我在 Web 开发领域仍然是一个完全的初学者,我正在尝试设置 Django 环境。我正在阅读《django 权威指南》来开始我的实践。

我在 MacBook 2.1GHz 上运行 Snow Leopard (10.6.2)。它附带了 Python 2.6.1。由于 Snow Leopard cam 预装了 Python 2.6.1,所以我没有做任何额外的设置。 也许它需要更多设置,请告诉我。但我已经运行了它,并且它有效。

我直接从书中安装了 django。我已经运行了它,到目前为止它有效。

数据库配置是令我窒息的一个。

我尝试使用 Python 的 MySQLdb 模块安装 MySQL,但它因 32 和 32 之间的差异而变得复杂。 64 位架构(mysql 有 64 位,python 有 32 位,反之亦然;无论哪种方式,我都无法弄清楚)。我读了很多论坛并修改了几个小时,仍然无法修复它,我就放弃了。

所以我尝试了下一个最好的办法(或者我是这么认为的),让我们尝试设置 Postgre。因此,我访问了 Postgre 官方网站并选择了 Mac OS X 安装包。我下载它,解压它,它只有一个“.app”安装程序和一个“自述文件”。我运行了安装程序,等等,我按照说明操作,它做了这个,它做了那个。最后,显然 Postgre 已安装。

我不确定它是否已安装,因此我在互联网上搜索了一些答案。嗯,我找到了安装Django for Mac的官方文档,但是安装步骤 Postgre 则完全不同。也许“.app”安装程序完成了这些步骤中列出的大部分配置,我不知道。

然后我进入终端并输入:(

psql -V

检查我刚刚安装的 Postgre 版本)

并且

sudo -u postgres pg_ctl start

(运行数据库)

找不到“psql”或“pg_ctl”命令。对我来说,这意味着 Postgre 没有安装或者我还需要做一些设置。

因此,我开始根据 Django 给出的指令(上面的链接)查看安装 Postgre 的第一步。从它说编辑“~/.profile”的说明来看,即使取消隐藏所有文件和目录,我仍然无法在我的用户目录下找到它。

此时我只是有点沮丧,不知道该去哪里。我想知道此时我是否可以获得一些指导/提示/操作方法/任何东西。

在运行 Postgre 之前我无法真正安装 psycopg2,但从它的外观来看,安装它看起来并没有那么糟糕(或者我希望如此)。

非常非常感谢您的帮助 ^_^

-Tri

I'm still a complete beginner in the field of web development and I'm trying to set up the Django environment. I'm reading "the definitive guide to django" to start my practice.

I'm running Snow Leopard (10.6.2) on a macbook 2.1GHz. It came with Python 2.6.1. Since Snow Leopard cam with Python 2.6.1 preinstalled, so I didn't do any extra set up. Maybe it needs more setup, please let me know. But I've ran it, and it works.

I installed django straight right from the book. I've ran it, and so far it works.

The Database configuration is the one stifling me.

I tried installing MySQL with MySQLdb module for python, but it had complications with the difference between 32 & 64 bit architecture (either mysql had 64 and python had 32 OR vice versa; Either way, I couldn't figure it out). I've read many forums and tinkered with it for hours, still couldn't fix it and I just gave up.

So I tried the next best thing (or so I thought), Let's try to set up Postgre instead. So, I went to the official Postgre website and picked the Mac OS X installment package. I download it, extract it, and all it had was an ".app" installer and a "README". I ran the installer, blah blah blah, I followed the instruction, it did this, it did that. At the end, apparently Postgre is installed.

I didn't feel completely sure if it was installed, so I searched around the internet for some answers. Well, I found the official documentation for installing Django for Mac, but the steps to install
Postgre was completely different. Maybe the ".app" installer did most of the configuration listed in those steps, I don't know.

Then I went to the terminal and type in:

psql -V

(to check which version of Postgre I just installed)

AND

sudo -u postgres pg_ctl start

(to run the database)

'psql' or 'pg_ctl' commands could not be found. To me, this is kind of saying Postgre was not installed or there are some setup I still need to do.

So I started looking at the first steps of installing Postgre from the given instruction by Django (link above). From the instruction it says to edit the '~/.profile', even after unhiding all the files and directories, I still can't find it under my user directory.

At this point I'm just kind of frustrated and don't know where to go. I was wondering if I can get some direction/tips/howto/anythingreallyatthispoint.

I can't really install psycopg2 until I have Postgre running, but from the looks of it, it doesn't look so bad to install it (or so I hope).

Many Many thanks in advance for any help ^_^

-Tri

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

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

发布评论

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

评论(4

违心° 2024-08-22 20:34:51

如果你刚刚开始,我会先尝试 sqlite。它是基于文件的,因此几乎不需要配置。稍后,如果您想升级到真正的数据库,那么它不会比您现在尝试的更困难。

If you're just getting started, I would try sqlite first. It's file based, so there is almost no configuration. Later, if you want to upgrade to a real database, then it won't be any harder than what you're attempting now.

幸福%小乖 2024-08-22 20:34:51

安装这些应用程序的最简单方法是通过 macports (http://www.macports.org/) 。根据我的经验,安装快速且干净。 geodjango安装文档对此有一个很好的部分: http://geodjango.org/docs/install .html#macports

the easiest way to install these apps would be via macports (http://www.macports.org/). in my experience, the installation was fast and clean. the geodjango installation documentation has a good section on this: http://geodjango.org/docs/install.html#macports.

醉南桥 2024-08-22 20:34:51

我怀疑您遇到的唯一问题是没有设置路径。将其添加到您的 ~/.bash_profile 中:

export PATH=/Library/PostgreSQL/8.4/bin:$PATH

现在您应该能够运行 psql 等命令行工具。

I suspect the only problem you are having is not setting path. Add this to your ~/.bash_profile:

export PATH=/Library/PostgreSQL/8.4/bin:$PATH

Now you should be able to run the command line tools like psql.

断念 2024-08-22 20:34:51

我只花了几个小时完成了多个不同的演练。这是最终起作用的:

首先使用 dmg 安装 postgress:
http://www.enterprisedb.com/products-services-training/pgdownload#osx

然后按照本教程操作:
http://stubblog.wordpress.com/2009/06/ 07/installing-psycopg2-on-osx/

然后将其放入终端 export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib:$DYLD_LIBRARY_PATH

我很确定这些是重要的我所做的部分内容..

如果您遇到错误,请尝试 sudo pip uninstall psycopg2 然后 sudo pip install psycopg2

如果您不断收到有关“....某些内容 <10.4”的错误”,重新安装 pip。我想我使用了诸如 brew install python 之类的东西来更新 python...如果你没有自制软件,请获取它。我很确定这就是消除该错误的原因..不过,它可能是手动安装的 pip3 。

抱歉,这到处都是,但它应该会让你更接近一点。至少,如果您(像我一样)没有使用其他教程。

I just spent a couple hours going through multiple different walkthroughs. This was the one that eventually worked:

first install postgress with the dmg:
http://www.enterprisedb.com/products-services-training/pgdownload#osx

then follow this tutorial:
http://stubblog.wordpress.com/2009/06/07/installing-psycopg2-on-osx/

then put this in terminal export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib:$DYLD_LIBRARY_PATH

And I'm pretty sure those were the important parts of what I did..

if you get errors try sudo pip uninstall psycopg2 then sudo pip install psycopg2

if you keep getting errors about ".... something < 10.4", reinstall pip. I think I used something like brew install python to update python... if you don't have homebrew, get it. I'm pretty sure that's what got rid of that error.. it may have been a manual install of pip3 though.

Sorry this is all over the place, it should get you a bit closer though. At least, if you (like me) have had none of the other tutorials work.

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