Zulko / gizeh

Simple Vector Graphics for Python
Other
704 stars 69 forks source link

Issue when importing gizeh #2

Open SamGRosen opened 10 years ago

SamGRosen commented 10 years ago

When simply running: import gizeh

I get the error: Traceback (most recent call last): File "C:\Users\Sam\Documents\Python\python 2.7\animations.py", line 6, in main() File "C:\Users\Sam\Documents\Python\python 2.7\animations.py", line 3, in main import gizeh File "build\bdist.win32\egg\gizehinit.py", line 5, in File "build\bdist.win32\egg\gizeh\gizeh.py", line 4, in File "build\bdist.win32\egg\cairocffiinit.py", line 40, in File "build\bdist.win32\egg\cairocffiinit.py", line 34, in dlopen File "C:\Python27\lib\site-packages\cffi\api.py", line 118, in dlopen lib, function_cache = _make_ffi_library(self, name, flags) File "C:\Python27\lib\site-packages\cffi\api.py", line 411, in _make_ffi_library backendlib = _load_backend_lib(backend, libname, flags) File "C:\Python27\lib\site-packages\cffi\api.py", line 400, in _load_backend_lib return backend.load_library(name, flags) OSError: cannot load library libcairo.so.2: error 0x7e I had a lot of difficulty installing due to some pip issues and had to install cairocffi, gizeh and numpy manually

Zulko commented 10 years ago

Thanks for the feedback. Can you also report the pip issues ? What did they look like ? You will need to install Cairo (I thought it was automatically installed with cairocffi but apparently not).

http://cairographics.org/download/

Tell me if it works after you installed Cairo.

SamGRosen commented 10 years ago

Pip error http://pastebin.com/q6gKfYPL

RealJTG commented 10 years ago

@GreenVars you need Visual Studio installed to build C/C++ extensions or you may download precompiled binaries here http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

cannot load library libcairo.so.2

I used this all-in-one installer http://sourceforge.net/projects/gtk-win/, works fine

Zulko commented 10 years ago

@GreenVars @RealJTG Maybe it would be simpler to get the binaries here: http://sourceforge.net/projects/numpy/files/NumPy/1.9.0/

Also, that's the first time I see this error.

SamGRosen commented 10 years ago

I have installed numpy and the all in one installer and am getting the same error.

josecarrascore commented 10 years ago

Hi, good library!, but I have any problems. I work on OS X Mavericks and I have installed Cairo library and followings python libraries: cairocffi (0.6) cffi (0.8.6) distribute (0.7.3) ez-setup (0.9) gizeh (0.1.06) numpy (1.9.0) pip (1.5.6) pycparser (2.10) setuptools (3.6) And I have same problem that GreenVars when import gizeh in Python 3.4.1 Thanks

Zulko commented 10 years ago

Can you paste the whole error that you get ? maybe there will be more infos.

josecarrascore commented 10 years ago

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import gizeh Traceback (most recent call last): File "", line 1, in File "", line 2237, in _find_and_load File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked File "", line 1161, in _load_backward_compatible File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/gizeh-0.1.06-py3.4.egg/gizeh/init.py", line 5, in File "", line 2237, in _find_and_load File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked File "", line 1161, in _load_backward_compatible File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/gizeh-0.1.06-py3.4.egg/gizeh/gizeh.py", line 4, in File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/cairocffi/init.py", line 41, in cairo = dlopen(ffi, *CAIRO_NAMES) File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/cairocffi/init.py", line 34, in dlopen return ffi.dlopen(names[0]) # pragma: no cover File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/cffi/api.py", line 118, in dlopen lib, function_cache = _make_ffi_library(self, name, flags) File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/cffi/api.py", line 411, in _make_ffi_library backendlib = _load_backend_lib(backend, libname, flags) File "/Users/josecarrascore/Proyectos/Gizeh_Moviepy/venv/lib/python3.4/site-packages/cffi/api.py", line 400, in _load_backend_lib return backend.load_library(name, flags) OSError: cannot load library libcairo.so.2: dlopen(libcairo.so.2, 2): image not found

Zulko commented 10 years ago

@josecarrascore @GreenVars Same answer as for GreenVars: have you installed Cairo on your computer? I will make that clearer in the docs, but the idea is that Gizeh relies on a C program called Cairo (which does all the drawing job)

josecarrascore commented 10 years ago

Yes, I installed Cairo. During the installation, Cairo refer to Python 2.7:

---> Fetching archive for python27 ---> Attempting to fetch python27-2.7.8_1.darwin_13.x86_64.tbz2 from http://lil.fr.packages.macports.org/python27 ---> Attempting to fetch python27-2.7.8_1.darwin_13.x86_64.tbz2.rmd160 from http://lil.fr.packages.macports.org/python27 ---> Installing python27 @2.7.8_1 ---> Activating python27 @2.7.8_1 ---->To make python 2.7 the default (i.e. the version you get when you run 'python'), please run: ----> sudo port select --set python python27

Can Python 3.4.1 work with Cairo?

Thanks.

Zulko commented 10 years ago

Hello @GreenVars @josecarrascore , a fellow Mac user posted the detail of what he installed to make everything work:

http://zulko.github.io/blog/2014/09/20/vector-animations-with-python/#comment-1609747524

If you want to give it a try, please tell me if it worked for you.

bzamecnik commented 9 years ago

As said in: https://github.com/Kozea/WeasyPrint/issues/79#issuecomment-28835056:

$ export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib

Works with macports and Python 3.4. Can be put into ~/.profile.

jai-singhal commented 8 years ago

Hey I installed Cairo as mentioned in first reply. Still I am get error. Please help to resolve this error

Traceback (most recent call last): File "C:\Python34\vector.py", line 1, in import gizeh File "C:\Python34\lib\site-packages\gizehinit.py", line 5, in from .gizeh import * File "C:\Python34\lib\site-packages\gizeh\gizeh.py", line 4, in import cairocffi as cairo File "C:\Python34\lib\site-packages\cairocffiinit.py", line 46, in cairo = dlopen(ffi, 'cairo', 'cairo-2') File "C:\Python34\lib\site-packages\cairocffiinit.py", line 43, in dlopen raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names)) OSError: dlopen() failed to load a library: cairo / cairo-2

Myousri commented 7 years ago

Here is what I have done to overcome this dlopen fail problem.

I installed the appropriate Pycairo executable whl from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo select the version that matches your python version, for example: pycairo‑1.13.0‑cp27‑cp27m‑win32.whl is for python 2.7 32 bit architecture

After installing gizeh, I opened gizeh.py and replaced the following line:

"import cairocffi as cairo" with "import cairo"

I am not sure how dangerous this hack, I think @Zulko who can better tell us. After this modification, I made another change in pillowmulti.py by adding "quantizer=1" before line 333. Again, I am not sure how badly this affects the performance of gizeh.py. However, after these couple of changes, I was able to run the examples in the following link successfully and generate the corresponding images: http://zulko.github.io/blog/2014/09/20/vector-animations-with-python/

In case things did not work with you, for your information, I am working on winpython 3.5 64 bit which can be installed from the following link: https://winpython.github.io/

It is a portable python release for scientific and educational usage.

JagritGumber commented 4 months ago

Here is what I have done to overcome this dlopen fail problem.

I installed the appropriate Pycairo executable whl from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo select the version that matches your python version, for example: pycairo‑1.13.0‑cp27‑cp27m‑win32.whl is for python 2.7 32 bit architecture

After installing gizeh, I opened gizeh.py and replaced the following line:

"import cairocffi as cairo" with "import cairo"

I am not sure how dangerous this hack, I think @Zulko who can better tell us. After this modification, I made another change in pillowmulti.py by adding "quantizer=1" before line 333. Again, I am not sure how badly this affects the performance of gizeh.py. However, after these couple of changes, I was able to run the examples in the following link successfully and generate the corresponding images: http://zulko.github.io/blog/2014/09/20/vector-animations-with-python/

In case things did not work with you, for your information, I am working on winpython 3.5 64 bit which can be installed from the following link: https://winpython.github.io/

It is a portable python release for scientific and educational usage.

I am maybe a whole lot late for this, but I did the same I went to gizeh.py and made this line import cairocffi as cairo to be this import cairo

For some reason this just works, I wasn't able to install the thing in the first comment