Snow Leopard 上的 mod_wsgi python 版本不匹配

发布于 2024-08-15 09:19:00 字数 3020 浏览 2 评论 0原文

我尝试在 Mac OS X 10.6 上使用非默认 python 安装在 Apache 2.2.14 下运行 mod_wsgi 3.1。

下载 mod_wsgi 源代码后,我运行:

sudo apachectl -k stop

然后

./configure --with-python=/usr/local/Cellar/python/2.6.4/bin/python
make
sudo make install

我再次启动 apache

sudo apachectl -k start

当我 cat /var/log/httpd/error_log 时,我看到:

[2009 年 12 月 21 日星期一 12:27:26] [警告] mod_wsgi:针对 Python/2.6.4 编译。

[2009 年 12 月 21 日星期一 12:27:26] [警告] mod_wsgi:使用 Python/2.6.1 的运行时。

[Mon Dec 21 12:27:26 2009] [通知] Apache/2.2.14 (Unix) DAV/2 mod_wsgi/3.1 Python/2.6.1 已配置 -- 恢复正常操作

当我运行 otool -L mod_wsgi.so 时,会看到:

mod_wsgi.so:

/System/Library/Frameworks/Python.framework/Versions/2.6/Python(兼容版本2.6.0,当前版本2.6.1)

/usr/lib/libSystem.B.dylib(兼容版本1.0.0,当前版本125.0.0)

给出了什么?为什么要和系统框架挂钩呢?

这是我的 mod_wsgi 配置和构建命令的输出:


Archimedes:mod_wsgi-3.1 awolf$ ./configure --with-python=/usr/local/Cellar/python/2.6.4/bin/python

检查 apxs2...不

检查 apxs... /opt/apache2/bin/apxs

检查 Apache 版本... 2.2.14

配置:创建 ./config.status

config.status:创建 Makefile

Archimedes:mod_wsgi-3.1 awolf$ make

/opt/apache2 /bin/apxs -c -I/usr/local/Cellar/python/2.6.4/include/python2.6 -DNDEBUG -Wc,'-arch x86_64' mod_wsgi.c -L/usr/local/Cellar/python/ 2.6.4/lib -L/usr/local/Cellar/python/2.6.4/lib/python2.6/config -arch x86_64 -lpython2.6 -ldl /Library/Webserver/build/libtool --silent --mode=编译 gcc -prefer-pic -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -g -O2 -I/opt/apache2/include -I/opt/apache2/包括-I/opt/apache2/include -arch x86_64 -I/usr/local/Cellar/python/2.6.4/include/python2.6 -DNDEBUG -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo

在 /usr/local/Cellar/python/2.6.4/include/python2.6/Python.h:125、/usr/local/Cellar/python/2.6.4/include/python2 包含的文件中

             from mod_wsgi.c:135:

。 6/modsupport.h:27:警告:“PyArg_ParseTuple”是无法识别的格式函数类型 /Library/Webserver/build/libtool --silent --mode=link gcc -o mod_wsgi.la -rpath /opt/apache2/modules -module -avoid-version mod_wsgi.lo -L/usr/local/Cellar/python/ 2.6.4/lib -L/usr/local/Cellar/python/2.6.4/lib/python2.6/config -arch x86_64 -lpython2.6 -ldl

阿基米德:mod_wsgi-3.1 awolf$ sudo make install

密码:

/opt /apache2/bin/apxs -i -S LIBEXECDIR=/opt/apache2/modules -n 'mod_wsgi' mod_wsgi.la

/Library/Webserver/build/instdso.sh SH_LIBTOOL='/Library/Webserver/build/libtool' mod_wsgi。 la /opt/apache2/modules

/Library/Webserver/build/libtool --mode=install cp mod_wsgi.la /opt/apache2/modules/

cp .libs/mod_wsgi.so /opt/apache2/modules/mod_wsgi.so

cp 。 libs/mod_wsgi.lai /opt/apache2/modules/mod_wsgi.la

cp .libs/mod_wsgi.a /opt/apache2/modules/mod_wsgi.a

chmod 644 /opt/apache2/modules/mod_wsgi.a

ranlib /opt/apache2/模块/mod_wsgi.a

I'm trying to run mod_wsgi 3.1 under Apache 2.2.14 using a non-default python installation on Mac OS X 10.6.

After downloading the mod_wsgi source I run:

sudo apachectl -k stop

then

./configure --with-python=/usr/local/Cellar/python/2.6.4/bin/python
make
sudo make install

I then start up apache again

sudo apachectl -k start

When I cat /var/log/httpd/error_log I see:

[Mon Dec 21 12:27:26 2009] [warn] mod_wsgi: Compiled for Python/2.6.4.

[Mon Dec 21 12:27:26 2009] [warn] mod_wsgi: Runtime using Python/2.6.1.

[Mon Dec 21 12:27:26 2009] [notice] Apache/2.2.14 (Unix) DAV/2 mod_wsgi/3.1 Python/2.6.1 configured -- resuming normal operations

When I run otool -L mod_wsgi.so is see:

mod_wsgi.so:

/System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)

/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)

What gives? Why is it linking with the system framework?

Here is the output from my mod_wsgi configure and build commands:


Archimedes:mod_wsgi-3.1 awolf$ ./configure --with-python=/usr/local/Cellar/python/2.6.4/bin/python

checking for apxs2... no

checking for apxs... /opt/apache2/bin/apxs

checking Apache version... 2.2.14

configure: creating ./config.status

config.status: creating Makefile

Archimedes:mod_wsgi-3.1 awolf$ make

/opt/apache2/bin/apxs -c -I/usr/local/Cellar/python/2.6.4/include/python2.6 -DNDEBUG -Wc,'-arch x86_64' mod_wsgi.c -L/usr/local/Cellar/python/2.6.4/lib -L/usr/local/Cellar/python/2.6.4/lib/python2.6/config -arch x86_64 -lpython2.6 -ldl
/Library/Webserver/build/libtool --silent --mode=compile gcc -prefer-pic -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp -g -O2 -I/opt/apache2/include -I/opt/apache2/include -I/opt/apache2/include -arch x86_64 -I/usr/local/Cellar/python/2.6.4/include/python2.6 -DNDEBUG -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo

In file included from /usr/local/Cellar/python/2.6.4/include/python2.6/Python.h:125,

             from mod_wsgi.c:135:

/usr/local/Cellar/python/2.6.4/include/python2.6/modsupport.h:27: warning: 'PyArg_ParseTuple' is an unrecognized format function type
/Library/Webserver/build/libtool --silent --mode=link gcc -o mod_wsgi.la -rpath /opt/apache2/modules -module -avoid-version mod_wsgi.lo -L/usr/local/Cellar/python/2.6.4/lib -L/usr/local/Cellar/python/2.6.4/lib/python2.6/config -arch x86_64 -lpython2.6 -ldl

Archimedes:mod_wsgi-3.1 awolf$ sudo make install

Password:

/opt/apache2/bin/apxs -i -S LIBEXECDIR=/opt/apache2/modules -n 'mod_wsgi' mod_wsgi.la

/Library/Webserver/build/instdso.sh SH_LIBTOOL='/Library/Webserver/build/libtool' mod_wsgi.la /opt/apache2/modules

/Library/Webserver/build/libtool --mode=install cp mod_wsgi.la /opt/apache2/modules/

cp .libs/mod_wsgi.so /opt/apache2/modules/mod_wsgi.so

cp .libs/mod_wsgi.lai /opt/apache2/modules/mod_wsgi.la

cp .libs/mod_wsgi.a /opt/apache2/modules/mod_wsgi.a

chmod 644 /opt/apache2/modules/mod_wsgi.a

ranlib /opt/apache2/modules/mod_wsgi.a

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

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

发布评论

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

评论(3

百思不得你姐 2024-08-22 09:19:01

这篇文章很旧,但仍然出现在有关 mac + homebrew + python 的搜索中,所以我想我应该添加一些有用的信息。我作为OP遇到了问题,只是使用了不同的模块(uwsgi)。我了解到你不必放弃自制软件。事实上,Homebrew 可以安装 python 作为框架;你只需要告诉它这样做:

% brew uninstall python
Uninstalling /usr/local/Cellar/python/2.7.2...
% brew install python --universal --framework

......一切都很好。

This post is old, but still turns up in searches about mac + homebrew + python, so I thought I'd add some useful information. I was having the problem as the OP, just with a different module (uwsgi). I learned that you don't have to abandon homebrew. Homebrew can, in fact, install python as a framework; you just have to tell it to do so:

% brew uninstall python
Uninstalling /usr/local/Cellar/python/2.7.2...
% brew install python --universal --framework

... and all's well.

孤星 2024-08-22 09:19:01

因为由于某种原因,某些从源代码安装的 Python 框架(通常是 MacPorts)在 Python 框架中嵌入的信息有问题,并且可执行文件的运行时查找路径设置不正确。因此,它最终使用 /System/Library 中的 Python 框架。

当您为 mod_wsgi 运行“configure”时,添加附加选项“--disable-framework”。例如:

./configure --with-python=/usr/local/Cellar/python/2.6.4/bin/python --disable-framework

这将改变 Python 库/框架的链接方式并可能解决问题。

有关详细信息,请参阅错误修复 (1) 和 (2):

http://code .google.com/p/modwsgi/wiki/ChangesInVersion0206

Because for some reason some Python framework installs from source code, usually MacPorts, have something wrong with the information embedded in the Python framework and the run time look up path of the executable isn't set correctly. As a result it ends up using the Python framework from /System/Library instead.

When you run 'configure' for mod_wsgi add the additional option '--disable-framework'. Eg:

./configure --with-python=/usr/local/Cellar/python/2.6.4/bin/python --disable-framework

This will change how Python library/framework is linked and may resolve the problem.

For more details see bug fixes (1) and (2) in:

http://code.google.com/p/modwsgi/wiki/ChangesInVersion0206

新雨望断虹 2024-08-22 09:19:01

Graham 帮助我在 mod_wsgi 邮件列表上解决了这个问题。

http://groups.google.com/group/modwsgi/ browser_thread/thread/4046eaf290a49b1e/ae14888450de39f5#ae14888450de39f5

这是一个总结:

问题是我的 python 安装是通过 Homebrew 完成的。 Homebrew 的 python 没有作为框架安装或 dylib 安装,因此它不能用于嵌入(例如在 Apache/mod_wsgi 中)。

相反,我从源代码安装了 python 2.6.4:

./configure --prefix=/usr/local/python-2.6.4 --enable-framework=/usr/local/python-2.6.4/frameworks --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.5 --with-universal-archs=3-way
make
sudo make install

我能够构建一个 python 2.6.4 版本,然后我可以构建它
mod_wsgi 与:

./configure --with-python=/usr/local/python-2.6.4/bin/python
make
sudo make install

确认:

otool -L /opt/apache2/modules/ mod_wsgi.so 

/opt/apache2/modules/mod_wsgi.so:
/usr/lib/libSystem.B.dylib(兼容版本1.0.0,当前
版本 125.0.0)
/usr/local/python-2.6.4/frameworks/Python.framework/Versions/2.6/Python(兼容版本2.6.0,当前版本2.6.0)

显示python现在使用的是2.6.4框架而不是系统一。当我启动 apache 时,我不再收到版本不匹配的警告。

我在新安装的 python 中重新安装了 django、psycopg2 等,一切都运行良好。
再次感谢您的帮助!

Graham helped me solve this over on the mod_wsgi mailing list.

http://groups.google.com/group/modwsgi/browse_thread/thread/4046eaf290a49b1e/ae14888450de39f5#ae14888450de39f5

Here's a summary:

The problem was my installation of python was done via Homebrew. Homebrew’s python is not installed as a framework OR dylib install so it could not be used for embedding (such as in Apache/mod_wsgi).

Instead I installed python 2.6.4 from source:

./configure --prefix=/usr/local/python-2.6.4 --enable-framework=/usr/local/python-2.6.4/frameworks --enable-universalsdk=/ MACOSX_DEPLOYMENT_TARGET=10.5 --with-universal-archs=3-way
make
sudo make install

I was able to build a version of python 2.6.4 that I could then build
mod_wsgi with:

./configure --with-python=/usr/local/python-2.6.4/bin/python
make
sudo make install

To confirm:

otool -L /opt/apache2/modules/ mod_wsgi.so 

/opt/apache2/modules/mod_wsgi.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 125.0.0)
/usr/local/python-2.6.4/frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.0)

shows that python is now using the 2.6.4 framework and not the system one. When I start apache, I no longer get the version mismatch warnings.

I re-installed django, psycopg2, and so on into my new python installation and everything is working like a charm.
Thanks again for your help!

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