开发者

Virtualenv virtualenvwrapper and _imaging

开发者 https://www.devze.com 2023-03-26 19:34 出处:网络
So my Mac is correctly set up with _imaging but as soon as I create a new virtualenv with mkvirtu开发者_如何学运维alenv myproject and run the python interpreter

So my Mac is correctly set up with _imaging but as soon as I create a new virtualenv with mkvirtu开发者_如何学运维alenv 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?


You will need to install it from source, see this google article. Do NOT use Mac Ports as that way lies madness.


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/


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消