Virtualenv virtualenvwrapper 和 _imaging

发布于 2024-11-27 22:28:49 字数 551 浏览 2 评论 0 原文

因此,我的 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 中?

So my Mac is correctly set up with _imaging but as soon as I create a new virtualenv with mkvirtualenv myproject and run the python interpreter

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

I get the following.

is there a quick fix to add my Imaging library to the virtualenv?

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

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

发布评论

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

评论(4

白芷 2024-12-04 22:28:49

您需要从源代码安装它,请参阅这篇 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.

护你周全 2024-12-04 22:28:49

不要相信前面的评论,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/

梦晓ヶ微光ヅ倾城 2024-12-04 22:28:49

当我指定 python 版本并确保 virtualenv 是自给自足的——没有使用站点包时,我感到最高兴。

将其添加到您的 .bashrc 中:

export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=python2.6'
source /usr/local/bin/virtualenvwrapper.sh

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:

export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=python2.6'
source /usr/local/bin/virtualenvwrapper.sh
樱花落人离去 2024-12-04 22:28:49

自从我从 10.6 升级到 10.7 以来,出现了一些问题,我花了几天时间才解决这个问题。

我现在已将 python 重新编译为 64 位,将 MySQL 重新编译为 64 位,并拥有功能齐全的 PIL、_imaging,甚至可以与 virtualenv 一起使用。

删除了我以前安装的所有 XCode。

下载64位版本的Python2.7.2并

在64位中安装重新编译的libjpeg

,首先是最新版本的libjpeg,我的是版本8c

sudo make clean
sudo CC="-arch x86_64" ./configure --enabled-static --enable-shared
make
sudo make install

,然后将Imaging-1.1.6

解压并cd进去

vi setup.py
JPEG_ROOT="/usr/local/lib"
sudo python setup.py install

并测试

然后你应该能够使用 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

sudo make clean
sudo CC="-arch x86_64" ./configure --enabled-static --enable-shared
make
sudo make install

and then get Imaging-1.1.6

untar and cd into

vi setup.py
JPEG_ROOT="/usr/local/lib"
sudo python setup.py install

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

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