gizeh icon indicating copy to clipboard operation
gizeh copied to clipboard

Issue when importing gizeh

Open SamGRosen opened this issue 10 years ago • 15 comments

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\gizeh__init__.py", line 5, in File "build\bdist.win32\egg\gizeh\gizeh.py", line 4, in File "build\bdist.win32\egg\cairocffi__init__.py", line 40, in File "build\bdist.win32\egg\cairocffi__init__.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

SamGRosen avatar Sep 23 '14 03:09 SamGRosen

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.

Zulko avatar Sep 23 '14 06:09 Zulko

Pip error http://pastebin.com/q6gKfYPL

SamGRosen avatar Sep 23 '14 21:09 SamGRosen

@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

RealJTG avatar Sep 24 '14 12:09 RealJTG

@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.

Zulko avatar Sep 24 '14 13:09 Zulko

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

SamGRosen avatar Sep 25 '14 02:09 SamGRosen

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

josecarrascore avatar Sep 27 '14 07:09 josecarrascore

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

Zulko avatar Sep 27 '14 07:09 Zulko

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

josecarrascore avatar Sep 27 '14 07:09 josecarrascore

@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)

Zulko avatar Sep 27 '14 07:09 Zulko

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.

josecarrascore avatar Sep 27 '14 13:09 josecarrascore

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.

Zulko avatar Sep 28 '14 19:09 Zulko

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.

bzamecnik avatar Jan 11 '15 13:01 bzamecnik

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\gizeh__init__.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\cairocffi__init__.py", line 46, in cairo = dlopen(ffi, 'cairo', 'cairo-2') File "C:\Python34\lib\site-packages\cairocffi__init__.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

jai-singhal avatar Aug 29 '16 14:08 jai-singhal

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.

Myousri avatar May 14 '17 00:05 Myousri