Virtualenv virtualenvwrapper 和 _imaging
因此,我的 Mac 已使用 _imaging 正确设置,但是当我使用 mkvirtualenv myproject 创建新的 virtualenv 并运行 python 解释器时,
import _imaging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/PIL/_imaging.so
我会得到以下信息。
有没有快速修复将我的成像库添加到 virtualenv 中?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要从源代码安装它,请参阅这篇 google 文章。不要使用 Mac Ports,因为那样会带来疯狂。
You will need to install it from source, see this google article. Do NOT use Mac Ports as that way lies madness.
不要相信前面的评论,Macports Python + PIL 工作得很好:)
根据错误消息,您可能以某种方式将 OSX 自己的 Python 和库与 Macports 的(错误版本)混合在一起。
使用Macports Python安装virtualenv,而不是OSX Python(命令行开关强制解释器)
安装本机依赖库到 Macports(列表在哪里...我已经有了)
easy_install PIL - 这应该编译 PIL 并编译后打印状态报告(JPEG:OK,PNG:OK等)
...或者您可以将 PIL 符号链接到您的 virtualenv ...:
http://blog.mfabrik.com/2009/11/19/installing-python-imaging-library-pil-under-virtualenv-or-buildout/
Do not believe the previous comment, Macports Python + PIL works just fine :)
Based on error message you are probably somehow mixing OSX own Python and libraries with Macports ones (wrong versions).
Install virtualenv using Macports Python, not OSX Python (command line switch to force the interpreter)
Install native dependency libs to Macports (where is the list... I have had it)
easy_install PIL - this should compile PIL and print status report (JPEG: OK, PNG: OK, etc.) after compilation
... OR you can symlink PIL to your virtualenv ...:
http://blog.mfabrik.com/2009/11/19/installing-python-imaging-library-pil-under-virtualenv-or-buildout/
当我指定 python 版本并确保 virtualenv 是自给自足的——没有使用站点包时,我感到最高兴。
将其添加到您的 .bashrc 中:
I have been happiest when I specified the python version and made sure that the virtualenv was self-sufficient -- no site-packages used.
Add this to your .bashrc:
自从我从 10.6 升级到 10.7 以来,出现了一些问题,我花了几天时间才解决这个问题。
我现在已将 python 重新编译为 64 位,将 MySQL 重新编译为 64 位,并拥有功能齐全的 PIL、_imaging,甚至可以与 virtualenv 一起使用。
删除了我以前安装的所有 XCode。
下载64位版本的Python2.7.2并
在64位中安装重新编译的libjpeg
,首先是最新版本的libjpeg,我的是版本8c
,然后将Imaging-1.1.6
解压并cd进去
并测试
然后你应该能够使用 mkvirtualenv testenv 创建 virtualenv 并执行
sudo pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz
So there was a bit of an issue since I upgraded from 10.6 to 10.7 and it took me a few days to sort this out.
I have now subsequently re-compiled my python as 64 bit, MySQL as 64 bit and have a fully functional PIL, _imaging working even with virtualenv.
removed all my previous installations of XCode.
downloaded the 64 bit version of Python2.7.2 and installed
recompiled libjpeg in 64-bit
first of all the latest version of libjpeg, mine was version 8c
and then get Imaging-1.1.6
untar and cd into
and test
then you should be able to make your virtualenv with mkvirtualenv testenv and do
sudo pip install http://effbot.org/downloads/Imaging-1.1.6.tar.gz